Version 5.1 - All the GraphQL #32

Closed
timw4mail wants to merge 1160 commits from develop into master
7 changed files with 37 additions and 15 deletions
Showing only changes of commit c38b4b7f45 - Show all commits

View File

@ -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>

View File

@ -1317,3 +1317,8 @@ a:hover, a:active {
width: 50px;
height: 50px;
}
.cover_streaming_link .streaming-logo {
width: 20px;
height: 20px;
}

View File

@ -569,3 +569,8 @@ a:hover, a:active {
width: 50px;
height: 50px;
}
.cover_streaming_link .streaming-logo {
width: 20px;
height: 20px;
}

View File

@ -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
*

View File

@ -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();

View File

@ -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;
}
}

View File

@ -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,
];
}