From 12dfb491bc763f9f69187b066356fbdccb05e426 Mon Sep 17 00:00:00 2001 From: Timothy J Warren Date: Tue, 16 Oct 2018 14:22:47 -0400 Subject: [PATCH] Remove a reference to genres from an older version of the Kitsu API --- Jenkinsfile | 72 +++++++++---------- src/API/Kitsu/Model.php | 4 +- .../Transformer/AnimeListTransformer.php | 8 ++- .../Transformer/MangaListTransformer.php | 8 ++- .../Kitsu/Transformer/MangaTransformer.php | 7 +- 5 files changed, 54 insertions(+), 45 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 45affd49..ac979353 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,37 +1,37 @@ pipeline { - agent none - stages { - stage('PHP 7.1') { - agent { - docker { - image 'php:7.1-alpine' - args '-u root --privileged' - } - } - steps { - sh 'chmod +x ./build/docker_install.sh' - sh 'sh build/docker_install.sh' - sh 'apk add --no-cache php7-phpdbg' - sh 'curl -sS https://getcomposer.org/installer | php' - sh 'php composer.phar install --ignore-platform-reqs' - sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never' - } - } - stage('PHP 7.2') { - agent { - docker { - image 'php:7.2-alpine' - args '-u root --privileged' - } - } - steps { - sh 'chmod +x ./build/docker_install.sh' - sh 'sh build/docker_install.sh' - sh 'apk add --no-cache php7-phpdbg' - sh 'curl -sS https://getcomposer.org/installer | php' - sh 'php composer.phar install --ignore-platform-reqs' - sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never' - } - } - } -} \ No newline at end of file + agent none + stages { + stage('PHP 7.1') { + agent { + docker { + image 'php:7.1-alpine' + args '-u root --privileged' + } + } + steps { + sh 'chmod +x ./build/docker_install.sh' + sh 'sh build/docker_install.sh' + sh 'apk add --no-cache php7-phpdbg' + sh 'curl -sS https://getcomposer.org/installer | php' + sh 'php composer.phar install --ignore-platform-reqs' + sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never' + } + } + stage('PHP 7.2') { + agent { + docker { + image 'php:7.2-alpine' + args '-u root --privileged' + } + } + steps { + sh 'chmod +x ./build/docker_install.sh' + sh 'sh build/docker_install.sh' + sh 'apk add --no-cache php7-phpdbg' + sh 'curl -sS https://getcomposer.org/installer | php' + sh 'php composer.phar install --ignore-platform-reqs' + sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never' + } + } + } + } \ No newline at end of file diff --git a/src/API/Kitsu/Model.php b/src/API/Kitsu/Model.php index d10f1171..ec5e592c 100644 --- a/src/API/Kitsu/Model.php +++ b/src/API/Kitsu/Model.php @@ -558,7 +558,7 @@ final class Model { 'media_type' => 'Anime', 'status' => $status, ], - 'include' => 'media,media.genres,media.mappings,anime.streamingLinks', + 'include' => 'media,media.categories,media.mappings,anime.streamingLinks', 'sort' => '-updated_at' ]; @@ -618,7 +618,7 @@ final class Model { 'media_type' => 'Manga', 'status' => $status, ], - 'include' => 'media,media.genres,media.mappings', + 'include' => 'media,media.categories,media.mappings', 'page' => [ 'offset' => $offset, 'limit' => $limit diff --git a/src/API/Kitsu/Transformer/AnimeListTransformer.php b/src/API/Kitsu/Transformer/AnimeListTransformer.php index c32fe4b3..e7da03a5 100644 --- a/src/API/Kitsu/Transformer/AnimeListTransformer.php +++ b/src/API/Kitsu/Transformer/AnimeListTransformer.php @@ -42,7 +42,13 @@ final class AnimeListTransformer extends AbstractTransformer { $animeId = $item['relationships']['media']['data']['id']; $anime = $included['anime'][$animeId]; - $genres = array_column($anime['relationships']['genres'], 'name') ?? []; + $genres = []; + + foreach($anime['relationships']['categories'] as $genre) + { + $genres[] = $genre['title']; + } + sort($genres); $rating = (int) $item['attributes']['ratingTwenty'] !== 0 diff --git a/src/API/Kitsu/Transformer/MangaListTransformer.php b/src/API/Kitsu/Transformer/MangaListTransformer.php index faa4a365..28691ecb 100644 --- a/src/API/Kitsu/Transformer/MangaListTransformer.php +++ b/src/API/Kitsu/Transformer/MangaListTransformer.php @@ -43,7 +43,13 @@ final class MangaListTransformer extends AbstractTransformer { $mangaId = $item['relationships']['media']['data']['id']; $manga = $included['manga'][$mangaId]; - $genres = array_column($manga['relationships']['genres'], 'name') ?? []; + $genres = []; + + foreach ($manga['relationships']['categories'] as $genre) + { + $genres[] = $genre['title']; + } + sort($genres); $rating = (int) $item['attributes']['ratingTwenty'] !== 0 diff --git a/src/API/Kitsu/Transformer/MangaTransformer.php b/src/API/Kitsu/Transformer/MangaTransformer.php index fd235df5..6e9e35e1 100644 --- a/src/API/Kitsu/Transformer/MangaTransformer.php +++ b/src/API/Kitsu/Transformer/MangaTransformer.php @@ -35,12 +35,9 @@ final class MangaTransformer extends AbstractTransformer { { $genres = []; - foreach($item['included'] as $included) + foreach($included['categories'] as $cat) { - if ($included['type'] === 'categories') - { - $genres[] = $included['attributes']['title']; - } + $genres[] = $cat['title']; } sort($genres);