Use more efficient method of combining large sets of data from Kitsu

This commit is contained in:
Timothy Warren 2018-04-11 09:26:14 -04:00
parent c4332d0ccd
commit 204313abbf

View File

@ -26,7 +26,6 @@ use Aviat\AnimeClient\API\{
ParallelAPIRequest ParallelAPIRequest
}; };
use Aviat\AnimeClient\API\Enum\{ use Aviat\AnimeClient\API\Enum\{
AnimeWatchingStatus\Title,
AnimeWatchingStatus\Kitsu as KitsuWatchingStatus, AnimeWatchingStatus\Kitsu as KitsuWatchingStatus,
MangaReadingStatus\Kitsu as KitsuReadingStatus MangaReadingStatus\Kitsu as KitsuReadingStatus
}; };
@ -47,7 +46,7 @@ class Model {
use ContainerAware; use ContainerAware;
use KitsuTrait; use KitsuTrait;
const LIST_PAGE_SIZE = 100; protected const LIST_PAGE_SIZE = 100;
/** /**
* Class to map anime list items * Class to map anime list items
@ -417,7 +416,7 @@ class Model {
* @param array $options * @param array $options
* @return array * @return array
*/ */
public function getFullAnimeList(array $options = [ public function getFullRawAnimeList(array $options = [
'include' => 'anime.mappings' 'include' => 'anime.mappings'
]): array ]): array
{ {
@ -441,10 +440,10 @@ class Model {
foreach($responses as $response) foreach($responses as $response)
{ {
$data = Json::decode($response); $data = Json::decode($response);
$output = array_merge_recursive($output, $data); $output[] = $data;
} }
return $output; return array_merge_recursive(...$output);
} }
/** /**
@ -547,7 +546,7 @@ class Model {
'sort' => '-updated_at' 'sort' => '-updated_at'
]; ];
return $this->getFullAnimeList($options); return $this->getFullRawAnimeList($options);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -680,7 +679,7 @@ class Model {
* @param array $options * @param array $options
* @return array * @return array
*/ */
public function getFullMangaList(array $options = [ public function getFullRawMangaList(array $options = [
'include' => 'manga.mappings' 'include' => 'manga.mappings'
]): array ]): array
{ {
@ -704,10 +703,10 @@ class Model {
foreach($responses as $response) foreach($responses as $response)
{ {
$data = Json::decode($response); $data = Json::decode($response);
$output = array_merge_recursive($output, $data); $output[] = $data;
} }
return $output; return array_merge_recursive(...$output);
} }
/** /**