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

This commit is contained in:
Peter Deltchev 2015-09-07 13:28:21 -07:00
parent b66ec54221
commit 47b172ccc4
4 changed files with 41 additions and 41 deletions

View file

@ -119,16 +119,16 @@
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)
@ -177,4 +177,4 @@
return Response::json(["artists" => $users, "current_page" => $page, "total_pages" => ceil($count / $perPage)], 200);
}
}
}

View file

@ -112,24 +112,24 @@
$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),
@ -137,7 +137,7 @@
],
'url' => $album->url,
'user' => [
'id' => $album->user->id,
'id' => (int) $album->user->id,
'name' => $album->user->display_name,
'url' => $album->user->url,
],
@ -282,4 +282,4 @@
private function getCacheKey($key) {
return 'album-' . $this->id . '-' . $key;
}
}
}

View file

@ -75,25 +75,25 @@
$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),
@ -101,7 +101,7 @@
],
'url' => $playlist->url,
'user' => [
'id' => $playlist->user->id,
'id' => (int) $playlist->user->id,
'name' => $playlist->user->display_name,
'url' => $playlist->user->url,
],
@ -190,4 +190,4 @@
private function getCacheKey($key) {
return 'playlist-' . $this->id . '-' . $key;
}
}
}

View file

@ -163,41 +163,41 @@
$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,