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> <tr>
<td><label for="rereading_flag">Rereading?</label></td> <td><label for="rereading_flag">Rereading?</label></td>
<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 ?> <?php if($item['rereading'] === TRUE): ?>checked="checked"<?php endif ?>
/> />
</td> </td>

View File

@ -1316,4 +1316,9 @@ a:hover, a:active {
.streaming-logo { .streaming-logo {
width: 50px; width: 50px;
height: 50px; height: 50px;
}
.cover_streaming_link .streaming-logo {
width: 20px;
height: 20px;
} }

View File

@ -568,4 +568,9 @@ a:hover, a:active {
.streaming-logo { .streaming-logo {
width: 50px; width: 50px;
height: 50px; height: 50px;
}
.cover_streaming_link .streaming-logo {
width: 20px;
height: 20px;
} }

View File

@ -42,6 +42,16 @@ class JsonAPI {
*/ */
protected $data = []; 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 * Take organized includes and inline them, where applicable
* *

View File

@ -270,13 +270,9 @@ class Model {
if ( ! $cacheItem->isHit()) if ( ! $cacheItem->isHit())
{ {
$data = $this->getRequest('library-entries', $options); $data = $this->getRequest('library-entries', $options);
$data = JsonAPI::inlineRawIncludes($data, 'manga');
foreach($data['data'] as $i => &$item) $transformed = $this->mangaListTransformer->transformCollection($data);
{
$item['manga'] = $data['included'][$i];
}
$transformed = $this->mangaListTransformer->transformCollection($data['data']);
$cacheItem->set($transformed); $cacheItem->set($transformed);
$cacheItem->save(); $cacheItem->save();

View File

@ -97,16 +97,10 @@ class MangaListTransformer extends AbstractTransformer {
'reconsuming' => $rereading, 'reconsuming' => $rereading,
'reconsumeCount' => (int)$item['reread_count'], 'reconsumeCount' => (int)$item['reread_count'],
'notes' => $item['notes'], '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; return $map;
} }
} }

View File

@ -32,6 +32,18 @@ class MangaTransformer extends AbstractTransformer {
*/ */
public function transform($item) public function transform($item)
{ {
$genres = [];
foreach($item['included'] as $included)
{
if ($included['type'] === 'genres')
{
$genres[] = $included['attributes']['name'];
}
}
sort($genres);
return [ return [
'title' => $item['canonicalTitle'], 'title' => $item['canonicalTitle'],
'en_title' => $item['titles']['en'], 'en_title' => $item['titles']['en'],
@ -42,7 +54,7 @@ class MangaTransformer extends AbstractTransformer {
'volume_count' => $this->count($item['volumeCount']), 'volume_count' => $this->count($item['volumeCount']),
'synopsis' => $item['synopsis'], 'synopsis' => $item['synopsis'],
'url' => "https://kitsu.io/manga/{$item['slug']}", 'url' => "https://kitsu.io/manga/{$item['slug']}",
'genres' => $item['genres'], 'genres' => $genres,
]; ];
} }