Version 5.1 - All the GraphQL #32
@ -53,7 +53,7 @@
|
||||
<tr>
|
||||
<td><label for="rereading_flag">Rereading?</label></td>
|
||||
<td>
|
||||
<input type="checkbox" name="reareading" id="rereading_flag"
|
||||
<input type="checkbox" name="rereading" id="rereading_flag"
|
||||
<?php if($item['rereading'] === TRUE): ?>checked="checked"<?php endif ?>
|
||||
/>
|
||||
</td>
|
||||
|
@ -1316,4 +1316,9 @@ a:hover, a:active {
|
||||
.streaming-logo {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.cover_streaming_link .streaming-logo {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
@ -568,4 +568,9 @@ a:hover, a:active {
|
||||
.streaming-logo {
|
||||
width: 50px;
|
||||
height: 50px;
|
||||
}
|
||||
|
||||
.cover_streaming_link .streaming-logo {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
@ -42,6 +42,16 @@ class JsonAPI {
|
||||
*/
|
||||
protected $data = [];
|
||||
|
||||
public static function inlineRawIncludes(array &$data, string $key): array
|
||||
{
|
||||
foreach($data['data'] as $i => &$item)
|
||||
{
|
||||
$item[$key] = $data['included'][$i];
|
||||
}
|
||||
|
||||
return $data['data'];
|
||||
}
|
||||
|
||||
/**
|
||||
* Take organized includes and inline them, where applicable
|
||||
*
|
||||
|
@ -270,13 +270,9 @@ class Model {
|
||||
if ( ! $cacheItem->isHit())
|
||||
{
|
||||
$data = $this->getRequest('library-entries', $options);
|
||||
$data = JsonAPI::inlineRawIncludes($data, 'manga');
|
||||
|
||||
foreach($data['data'] as $i => &$item)
|
||||
{
|
||||
$item['manga'] = $data['included'][$i];
|
||||
}
|
||||
|
||||
$transformed = $this->mangaListTransformer->transformCollection($data['data']);
|
||||
$transformed = $this->mangaListTransformer->transformCollection($data);
|
||||
|
||||
$cacheItem->set($transformed);
|
||||
$cacheItem->save();
|
||||
|
@ -97,16 +97,10 @@ class MangaListTransformer extends AbstractTransformer {
|
||||
'reconsuming' => $rereading,
|
||||
'reconsumeCount' => (int)$item['reread_count'],
|
||||
'notes' => $item['notes'],
|
||||
'rating' => $item['new_rating'] / 2
|
||||
],
|
||||
];
|
||||
|
||||
if ($item['new_rating'] !== $item['old_rating'] && $item['new_rating'] !== "")
|
||||
{
|
||||
$map['data']['rating'] = ($item['new_rating'] > 0)
|
||||
? $item['new_rating'] / 2
|
||||
: $item['old_rating'] / 2;
|
||||
}
|
||||
|
||||
return $map;
|
||||
}
|
||||
}
|
||||
|
@ -32,6 +32,18 @@ class MangaTransformer extends AbstractTransformer {
|
||||
*/
|
||||
public function transform($item)
|
||||
{
|
||||
$genres = [];
|
||||
|
||||
foreach($item['included'] as $included)
|
||||
{
|
||||
if ($included['type'] === 'genres')
|
||||
{
|
||||
$genres[] = $included['attributes']['name'];
|
||||
}
|
||||
}
|
||||
|
||||
sort($genres);
|
||||
|
||||
return [
|
||||
'title' => $item['canonicalTitle'],
|
||||
'en_title' => $item['titles']['en'],
|
||||
@ -42,7 +54,7 @@ class MangaTransformer extends AbstractTransformer {
|
||||
'volume_count' => $this->count($item['volumeCount']),
|
||||
'synopsis' => $item['synopsis'],
|
||||
'url' => "https://kitsu.io/manga/{$item['slug']}",
|
||||
'genres' => $item['genres'],
|
||||
'genres' => $genres,
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user