Start of pulling library from GraphQL

This commit is contained in:
Timothy Warren 2020-08-25 13:22:38 -04:00
parent 3f8c0432d2
commit 980e2726c5
3 changed files with 102 additions and 16 deletions

View File

@ -390,27 +390,18 @@ final class Model {
private function getListCount(string $type, string $status = ''): int
{
$options = [
'query' => [
'filter' => [
'user_id' => $this->getUserId(),
'kind' => $type,
],
'page' => [
'limit' => 1
],
'sort' => '-updated_at'
]
$args = [
'type' => strtoupper($type),
'slug' => $this->getUsername()
];
if ( ! empty($status))
if ($status !== '')
{
$options['query']['filter']['status'] = $status;
$args['status'] = strtoupper($status);
}
$response = $this->requestBuilder->getRequest('library-entries', $options);
$res = $this->requestBuilder->runQuery('GetLibraryCount', $args);
return $response['meta']['count'];
return $res['data']['findProfileBySlug']['library']['all']['totalCount'];
}
/**

View File

@ -0,0 +1,86 @@
query ($slug: String!, $type: media_type!, $status: [LibraryEntryStatus!]) {
findProfileBySlug(slug: $slug) {
library {
all(mediaType: $type, status: $status) {
# pageInfo {
# endCursor
# hasNextPage
# hasPreviousPage
# startCursor
# }
totalCount
nodes {
id
notes
nsfw
private
progress
progressedAt
rating
reconsumeCount
reconsuming
status
media {
id
ageRating
ageRatingGuide
categories {
nodes {
title
}
}
mappings {
nodes {
externalId
externalSite
}
}
posterImage {
original {
height
name
url
width
}
views {
height
name
url
width
}
}
sfw
slug
status
type
titles {
canonical
localized
alternatives
}
...on Anime {
episodeCount
streamingLinks {
nodes {
dubs
subs
regions
streamer {
id
siteName
}
url
}
}
subtype
}
...on Manga {
chapterCount
subtype
}
}
}
}
}
}
}

View File

@ -0,0 +1,9 @@
query ($slug: String!, $type: media_type!, $status: [LibraryEntryStatus!]) {
findProfileBySlug(slug: $slug) {
library {
all(mediaType: $type, status: $status) {
totalCount
}
}
}
}