Browse Source

Remove a reference to genres from an older version of the Kitsu API

Timothy J. Warren 1 month ago
parent
commit
12dfb491bc

+ 36
- 36
Jenkinsfile View File

@@ -1,37 +1,37 @@
1 1
 pipeline {
2
-	agent none
3
-	stages {
4
-		stage('PHP 7.1') {
5
-			agent {
6
-				docker {
7
-				    image 'php:7.1-alpine'
8
-				    args '-u root --privileged'
9
-				}
10
-			}
11
-			steps {
12
-				sh 'chmod +x ./build/docker_install.sh'
13
-				sh 'sh build/docker_install.sh'
14
-				sh 'apk add --no-cache php7-phpdbg'
15
-				sh 'curl -sS https://getcomposer.org/installer | php'
16
-				sh 'php composer.phar install --ignore-platform-reqs'
17
-				sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
18
-			}
19
-		}
20
-		stage('PHP 7.2') {
21
-			agent {
22
-				docker {
23
-				    image 'php:7.2-alpine'
24
-				    args '-u root --privileged'
25
-				}
26
-			}
27
-			steps {
28
-				sh 'chmod +x ./build/docker_install.sh'
29
-				sh 'sh build/docker_install.sh'
30
-				sh 'apk add --no-cache php7-phpdbg'
31
-				sh 'curl -sS https://getcomposer.org/installer | php'
32
-				sh 'php composer.phar install --ignore-platform-reqs'
33
-				sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
34
-			}
35
-		}
36
-	}
37
-}
2
+ 	agent none
3
+ 	stages {
4
+ 		stage('PHP 7.1') {
5
+ 			agent {
6
+ 				docker {
7
+ 				    image 'php:7.1-alpine'
8
+ 				    args '-u root --privileged'
9
+ 				}
10
+ 			}
11
+ 			steps {
12
+ 				sh 'chmod +x ./build/docker_install.sh'
13
+ 				sh 'sh build/docker_install.sh'
14
+ 				sh 'apk add --no-cache php7-phpdbg'
15
+ 				sh 'curl -sS https://getcomposer.org/installer | php'
16
+ 				sh 'php composer.phar install --ignore-platform-reqs'
17
+ 				sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
18
+ 			}
19
+ 		}
20
+ 		stage('PHP 7.2') {
21
+ 			agent {
22
+ 				docker {
23
+ 				    image 'php:7.2-alpine'
24
+ 				    args '-u root --privileged'
25
+ 				}
26
+ 			}
27
+ 			steps {
28
+ 				sh 'chmod +x ./build/docker_install.sh'
29
+ 				sh 'sh build/docker_install.sh'
30
+ 				sh 'apk add --no-cache php7-phpdbg'
31
+ 				sh 'curl -sS https://getcomposer.org/installer | php'
32
+ 				sh 'php composer.phar install --ignore-platform-reqs'
33
+ 				sh 'phpdbg -qrr -- ./vendor/bin/phpunit --coverage-text --colors=never'
34
+ 			}
35
+ 		}
36
+ 	}
37
+ }

+ 2
- 2
src/API/Kitsu/Model.php View File

@@ -558,7 +558,7 @@ final class Model {
558 558
 				'media_type' => 'Anime',
559 559
 				'status' => $status,
560 560
 			],
561
-			'include' => 'media,media.genres,media.mappings,anime.streamingLinks',
561
+			'include' => 'media,media.categories,media.mappings,anime.streamingLinks',
562 562
 			'sort' => '-updated_at'
563 563
 		];
564 564
 
@@ -618,7 +618,7 @@ final class Model {
618 618
 					'media_type' => 'Manga',
619 619
 					'status' => $status,
620 620
 				],
621
-				'include' => 'media,media.genres,media.mappings',
621
+				'include' => 'media,media.categories,media.mappings',
622 622
 				'page' => [
623 623
 					'offset' => $offset,
624 624
 					'limit' => $limit

+ 7
- 1
src/API/Kitsu/Transformer/AnimeListTransformer.php View File

@@ -42,7 +42,13 @@ final class AnimeListTransformer extends AbstractTransformer {
42 42
 		$animeId = $item['relationships']['media']['data']['id'];
43 43
 		$anime = $included['anime'][$animeId];
44 44
 
45
-		$genres = array_column($anime['relationships']['genres'], 'name') ?? [];
45
+		$genres = [];
46
+
47
+		foreach($anime['relationships']['categories'] as $genre)
48
+		{
49
+			$genres[] = $genre['title'];
50
+		}
51
+
46 52
 		sort($genres);
47 53
 
48 54
 		$rating = (int) $item['attributes']['ratingTwenty'] !== 0

+ 7
- 1
src/API/Kitsu/Transformer/MangaListTransformer.php View File

@@ -43,7 +43,13 @@ final class MangaListTransformer extends AbstractTransformer {
43 43
 		$mangaId = $item['relationships']['media']['data']['id'];
44 44
 		$manga = $included['manga'][$mangaId];
45 45
 
46
-		$genres = array_column($manga['relationships']['genres'], 'name') ?? [];
46
+		$genres = [];
47
+
48
+		foreach ($manga['relationships']['categories'] as $genre)
49
+		{
50
+			$genres[] = $genre['title'];
51
+		}
52
+
47 53
 		sort($genres);
48 54
 
49 55
 		$rating = (int) $item['attributes']['ratingTwenty'] !== 0

+ 2
- 5
src/API/Kitsu/Transformer/MangaTransformer.php View File

@@ -35,12 +35,9 @@ final class MangaTransformer extends AbstractTransformer {
35 35
 	{
36 36
 		$genres = [];
37 37
 
38
-		foreach($item['included'] as $included)
38
+		foreach($included['categories'] as $cat)
39 39
 		{
40
-			if ($included['type'] === 'categories')
41
-			{
42
-				$genres[] = $included['attributes']['title'];
43
-			}
40
+			$genres[] = $cat['title'];
44 41
 		}
45 42
 
46 43
 		sort($genres);