Merge rPF47b172ccc49d: T366: Explicitly return ints and boolean values as such in the website API.

This commit is contained in:
Kelvin Zhang 2015-09-10 12:41:35 +01:00
parent 5a2fb2f05e
commit 05f1745b1f
4 changed files with 38 additions and 38 deletions

View file

@ -126,24 +126,24 @@ class Album extends Model
$userRow = $album->users[0];
$userData = [
'stats' => [
'views' => $userRow->view_count,
'downloads' => $userRow->download_count,
'views' => (int) $userRow->view_count,
'downloads' => (int) $userRow->download_count,
],
'is_favourited' => $userRow->is_favourited
'is_favourited' => (bool) $userRow->is_favourited
];
}
return [
'id' => $album->id,
'track_count' => $album->track_count,
'id' => (int) $album->id,
'track_count' => (int) $album->track_count,
'title' => $album->title,
'slug' => $album->slug,
'created_at' => $album->created_at,
'stats' => [
'views' => $album->view_count,
'downloads' => $album->download_count,
'comments' => $album->comment_count,
'favourites' => $album->favourite_count
'views' => (int) $album->view_count,
'downloads' => (int) $album->download_count,
'comments' => (int) $album->comment_count,
'favourites' => (int) $album->favourite_count
],
'covers' => [
'small' => $album->getCoverUrl(Image::SMALL),
@ -151,7 +151,7 @@ class Album extends Model
],
'url' => $album->url,
'user' => [
'id' => $album->user->id,
'id' => (int) $album->user->id,
'name' => $album->user->display_name,
'url' => $album->user->url,
],

View file

@ -133,16 +133,16 @@ class ArtistsController extends ApiControllerBase
if ($user->users->count()) {
$userRow = $user->users[0];
$userData = [
'is_following' => $userRow->is_followed
'is_following' => (bool)$userRow->is_followed
];
}
return Response::json([
'artist' => [
'id' => $user->id,
'id' => (int)$user->id,
'name' => $user->display_name,
'slug' => $user->slug,
'is_archived' => $user->is_archived,
'is_archived' => (bool)$user->is_archived,
'avatars' => [
'small' => $user->getAvatarUrl(Image::SMALL),
'normal' => $user->getAvatarUrl(Image::NORMAL)

View file

@ -86,25 +86,25 @@ class Playlist extends Model
$userRow = $playlist->users[0];
$userData = [
'stats' => [
'views' => $userRow->view_count,
'downloads' => $userRow->download_count,
'views' => (int) $userRow->view_count,
'downloads' => (int) $userRow->download_count,
],
'is_favourited' => $userRow->is_favourited
'is_favourited' => (bool) $userRow->is_favourited
];
}
return [
'id' => $playlist->id,
'id' => (int) $playlist->id,
'track_count' => $playlist->track_count,
'title' => $playlist->title,
'slug' => $playlist->slug,
'created_at' => $playlist->created_at,
'is_public' => $playlist->is_public,
'is_public' => (bool) $playlist->is_public,
'stats' => [
'views' => $playlist->view_count,
'downloads' => $playlist->download_count,
'comments' => $playlist->comment_count,
'favourites' => $playlist->favourite_count
'views' => (int) $playlist->view_count,
'downloads' => (int) $playlist->download_count,
'comments' => (int) $playlist->comment_count,
'favourites' => (int) $playlist->favourite_count
],
'covers' => [
'small' => $playlist->getCoverUrl(Image::SMALL),
@ -112,7 +112,7 @@ class Playlist extends Model
],
'url' => $playlist->url,
'user' => [
'id' => $playlist->user->id,
'id' => (int) $playlist->user->id,
'name' => $playlist->user->display_name,
'url' => $playlist->user->url,
],

View file

@ -229,41 +229,41 @@ class Track extends Model
$userRow = $track->users[0];
$userData = [
'stats' => [
'views' => $userRow->view_count,
'plays' => $userRow->play_count,
'views' => (int) $userRow->view_count,
'plays' => (int) $userRow->play_count,
'downloads' => $userRow->download_count,
],
'is_favourited' => $userRow->is_favourited
'is_favourited' => (bool) $userRow->is_favourited
];
}
return [
'id' => $track->id,
'id' => (int) $track->id,
'title' => $track->title,
'user' => [
'id' => $track->user->id,
'id' => (int) $track->user->id,
'name' => $track->user->display_name,
'url' => $track->user->url
],
'stats' => [
'views' => $track->view_count,
'plays' => $track->play_count,
'downloads' => $track->download_count,
'comments' => $track->comment_count,
'favourites' => $track->favourite_count
'views' => (int) $track->view_count,
'plays' => (int) $track->play_count,
'downloads' => (int) $track->download_count,
'comments' => (int) $track->comment_count,
'favourites' => (int) $track->favourite_count
],
'url' => $track->url,
'slug' => $track->slug,
'is_vocal' => $track->is_vocal,
'is_explicit' => $track->is_explicit,
'is_downloadable' => $track->is_downloadable,
'is_published' => $track->isPublished(),
'is_vocal' => (bool) $track->is_vocal,
'is_explicit' => (bool) $track->is_explicit,
'is_downloadable' => (bool) $track->is_downloadable,
'is_published' => (bool) $track->isPublished(),
'published_at' => $track->published_at,
'duration' => $track->duration,
'genre' => $track->genre != null
?
[
'id' => $track->genre->id,
'id' => (int) $track->genre->id,
'slug' => $track->genre->slug,
'name' => $track->genre->name
] : null,