Fix some edge cases

This commit is contained in:
Timothy Warren 2019-04-01 16:17:40 -04:00
parent 4c896349b9
commit 92243189ee
3 changed files with 27 additions and 3 deletions

View File

@ -422,8 +422,14 @@ final class Model {
$item['included'] = $included;
}
$transformed = $this->animeListTransformer->transformCollection($data['data']);
$keyed = [];
$cacheItem->set($transformed);
foreach($transformed as $item)
{
$keyed[$item['id']] = $item;
}
$cacheItem->set($keyed);
$cacheItem->save();
}

View File

@ -66,7 +66,7 @@ final class Manga extends Controller {
*/
public function index($status = 'all', $view = ''): void
{
if ( ! in_array($type, [
if ( ! in_array($status, [
'all',
'reading',
'plan_to_read',
@ -337,4 +337,4 @@ final class Manga extends Controller {
// @TODO: implement
}
}
// End of MangaController.php
// End of MangaController.php

View File

@ -29,6 +29,11 @@ class API {
*/
protected function sortByName(array &$array, string $sortKey): void
{
if (empty($array))
{
return;
}
$sort = [];
foreach ($array as $key => $item)
@ -37,5 +42,18 @@ class API {
}
array_multisort($sort, SORT_ASC, $array);
// Re-key array items by their ids
if (array_key_exists('id', $array[0]))
{
$keyed = [];
foreach($array as $item)
{
$keyed[$item['id']] = $item;
}
$array = $keyed;
}
}
}