Fix 'All' section on Manga page

This commit is contained in:
Timothy Warren 2017-03-07 18:41:51 -05:00
parent 26d339e546
commit b6dc104947
3 changed files with 26 additions and 5 deletions

View File

@ -21,10 +21,14 @@ use function Amp\{all, wait};
use Amp\Artax\{Client, Request};
use Aviat\AnimeClient\API\{
CacheTrait,
Enum\AnimeWatchingStatus\Title,
JsonAPI,
Kitsu as K,
Mapping\AnimeWatchingStatus
Mapping\AnimeWatchingStatus,
Mapping\MangaReadingStatus
};
use Aviat\AnimeClient\API\Enum\{
AnimeWatchingStatus\Title,
MangaReadingStatus\Kitsu as KitsuReadingStatus
};
use Aviat\AnimeClient\API\Kitsu\Transformer\{
AnimeTransformer,
@ -334,7 +338,6 @@ class Model {
public function getFullOrganizedAnimeList(): array
{
$cacheItem = $this->cache->getItem(self::FULL_TRANSFORMED_LIST_CACHE_KEY);
if ( ! $cacheItem->isHit())
@ -402,6 +405,19 @@ class Model {
return $cacheItem->get();
}
public function getFullOrganizedMangaList(): array
{
$statuses = KitsuReadingStatus::getConstList();
$output = [];
foreach ($statuses as $status)
{
$mappedStatus = MangaReadingStatus::KITSU_TO_TITLE[$status];
$output[$mappedStatus] = $this->getMangaList($status);
}
return $output;
}
/**
* Get the manga list for the configured user
*

View File

@ -84,7 +84,7 @@ class SyncKitsuWithMal extends BaseCommand {
for ($i = 0; $i < $count; $i++)
{
$offset = $i * $size;
$requests[] = $this->kitsuModel->getFullAnimeList($size, $offset);
$requests[] = $this->kitsuModel->getPagedAnimeList($size, $offset);
}
$promiseArray = (new Client())->requestMulti($requests);
@ -151,7 +151,7 @@ class SyncKitsuWithMal extends BaseCommand {
public function filterKitsuList()
{
$data = $this->getKitsuList();
$data = $this->kitsuModel->getFullAnimeList();
$includes = JsonAPI::organizeIncludes($data['included']);
$includes['mappings'] = $this->filterMappings($includes['mappings']);

View File

@ -56,6 +56,11 @@ class Manga extends API
*/
public function getList($status)
{
if ($status === 'All')
{
return $this->kitsuModel->getFullOrganizedMangaList();
}
$APIstatus = MangaReadingStatus::TITLE_TO_KITSU[$status];
$data = $this->kitsuModel->getMangaList($APIstatus);
return $this->mapByStatus($data)[$status];