Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
3 changed files with 15 additions and 9 deletions
Showing only changes of commit ed4f9152d4 - Show all commits

View File

@ -40,7 +40,9 @@ class AnimeListTransformer extends AbstractTransformer {
$genres = array_column($anime['relationships']['genres'], 'name') ?? [];
sort($genres);
$rating = (int) 2 * $item['attributes']['rating'];
$rating = (int) $item['attributes']['rating'] !== 0
? (int) 2 * $item['attributes']['rating']
: '-';
$total_episodes = array_key_exists('episodeCount', $anime) && (int) $anime['episodeCount'] !== 0
? (int) $anime['episodeCount']
@ -68,7 +70,7 @@ class AnimeListTransformer extends AbstractTransformer {
'id' => $item['id'],
'mal_id' => $MALid,
'episodes' => [
'watched' => (int) $item['attributes']['progress'] !== '0'
'watched' => (int) $item['attributes']['progress'] !== 0
? (int) $item['attributes']['progress']
: '-',
'total' => $total_episodes,
@ -93,7 +95,7 @@ class AnimeListTransformer extends AbstractTransformer {
'notes' => $item['attributes']['notes'],
'rewatching' => (bool) $item['attributes']['reconsuming'],
'rewatched' => (int) $item['attributes']['reconsumeCount'],
'user_rating' => ($rating === 0) ? '-' : (int) $rating,
'user_rating' => $rating,
'private' => (bool) $item['attributes']['private'] ?? FALSE,
];
}

View File

@ -42,18 +42,22 @@ class MangaListTransformer extends AbstractTransformer {
$genres = array_column($manga['relationships']['genres'], 'name') ?? [];
sort($genres);
$rating = (is_numeric($item['attributes']['rating']))
? intval(2 * $item['attributes']['rating'])
$rating = (int) $item['attributes']['rating'] !== 0
? (int) 2 * $item['attributes']['rating']
: '-';
$totalChapters = ($manga['chapterCount'] > 0)
$totalChapters = ((int) $manga['chapterCount'] !== 0)
? $manga['chapterCount']
: '-';
$totalVolumes = ($manga['volumeCount'] > 0)
$totalVolumes = ((int) $manga['volumeCount'] !== 0)
? $manga['volumeCount']
: '-';
$readChapters = ((int) $item['attributes']['progress'] !== 0)
? $item['attributes']['progress']
: '-';
$MALid = NULL;
if (array_key_exists('mappings', $manga['relationships']))
@ -72,7 +76,7 @@ class MangaListTransformer extends AbstractTransformer {
'id' => $item['id'],
'mal_id' => $MALid,
'chapters' => [
'read' => $item['attributes']['progress'],
'read' => $readChapters,
'total' => $totalChapters
],
'volumes' => [

View File

@ -3,7 +3,7 @@
'mal_id' => '33206',
'episodes' =>
array (
'watched' => 0,
'watched' => '-',
'total' => '-',
'length' => NULL,
),