2019-12-15 21:16:55 +00:00
|
|
|
import { graphql } from '../api';
|
2020-08-12 01:30:20 +00:00
|
|
|
import { releasesFragment, releaseFragment, releaseFields } from '../fragments';
|
2019-12-16 04:30:25 +00:00
|
|
|
import { curateRelease } from '../curate';
|
2020-05-07 01:20:51 +00:00
|
|
|
import getDateRange from '../get-date-range';
|
2019-06-03 03:31:38 +00:00
|
|
|
|
2019-12-18 01:42:55 +00:00
|
|
|
function initReleasesActions(store, _router) {
|
2020-05-22 02:32:16 +00:00
|
|
|
async function fetchReleases({ _commit }, { limit = 10, pageNumber = 1, range = 'latest' }) {
|
2020-05-14 02:26:05 +00:00
|
|
|
const { before, after, orderBy } = getDateRange(range);
|
2020-05-07 01:20:51 +00:00
|
|
|
|
2020-05-22 02:32:16 +00:00
|
|
|
const { connection: { releases, totalCount } } = await graphql(`
|
2019-12-18 01:42:55 +00:00
|
|
|
query Releases(
|
|
|
|
$limit:Int = 1000,
|
2020-05-22 02:32:16 +00:00
|
|
|
$offset:Int = 0,
|
2020-08-19 19:48:55 +00:00
|
|
|
$after:Datetime = "1900-01-01 00:00:00",
|
|
|
|
$before:Datetime = "2100-01-01 00:00:00",
|
|
|
|
$orderBy: [ReleasesOrderBy!],
|
2020-01-30 22:41:10 +00:00
|
|
|
$exclude: [String!]
|
2019-12-18 01:42:55 +00:00
|
|
|
) {
|
2019-12-16 04:30:25 +00:00
|
|
|
${releasesFragment}
|
2019-12-15 21:16:55 +00:00
|
|
|
}
|
2019-12-15 22:01:48 +00:00
|
|
|
`, {
|
2020-05-14 02:26:05 +00:00
|
|
|
limit,
|
2020-05-22 02:32:16 +00:00
|
|
|
offset: Math.max(0, (pageNumber - 1)) * limit,
|
2020-05-14 02:26:05 +00:00
|
|
|
after,
|
|
|
|
before,
|
|
|
|
orderBy,
|
|
|
|
exclude: store.state.ui.filter,
|
|
|
|
});
|
2019-12-15 21:16:55 +00:00
|
|
|
|
2020-05-22 02:32:16 +00:00
|
|
|
return {
|
|
|
|
releases: releases.map(release => curateRelease(release)),
|
|
|
|
totalCount,
|
|
|
|
};
|
2020-05-14 02:26:05 +00:00
|
|
|
}
|
2019-12-15 21:16:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
async function fetchReleaseById({ _commit }, releaseId) {
|
|
|
|
// const release = await get(`/releases/${releaseId}`);
|
2019-12-15 21:16:55 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
const { release } = await graphql(`
|
2019-12-15 21:16:55 +00:00
|
|
|
query Release($releaseId:Int!) {
|
2019-12-16 04:30:25 +00:00
|
|
|
${releaseFragment}
|
2019-12-15 04:42:51 +00:00
|
|
|
}
|
2019-12-15 21:16:55 +00:00
|
|
|
`, {
|
2020-05-14 02:26:05 +00:00
|
|
|
releaseId: Number(releaseId),
|
|
|
|
});
|
2019-11-15 01:37:17 +00:00
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return curateRelease(release);
|
|
|
|
}
|
2019-11-15 01:37:17 +00:00
|
|
|
|
2020-08-01 13:11:07 +00:00
|
|
|
async function fetchMovies({ _commit }, { limit = 10, pageNumber = 1 }) {
|
|
|
|
const { connection: { movies, totalCount } } = await graphql(`
|
|
|
|
query Movies(
|
|
|
|
$limit:Int = 1000,
|
|
|
|
$offset:Int = 0,
|
|
|
|
) {
|
|
|
|
connection: moviesConnection(
|
|
|
|
first: $limit
|
|
|
|
offset: $offset
|
2020-08-12 01:30:20 +00:00
|
|
|
orderBy: DATE_DESC
|
2020-08-01 13:11:07 +00:00
|
|
|
) {
|
|
|
|
movies: nodes {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
url
|
|
|
|
slug
|
|
|
|
date
|
|
|
|
datePrecision
|
2020-08-10 19:39:55 +00:00
|
|
|
actors {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
|
|
|
tags {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
2020-08-01 13:11:07 +00:00
|
|
|
entity {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
2020-08-10 19:39:55 +00:00
|
|
|
type
|
|
|
|
parent {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
type
|
|
|
|
}
|
2020-08-01 13:11:07 +00:00
|
|
|
}
|
2020-08-20 02:57:38 +00:00
|
|
|
covers: moviesCovers {
|
2020-08-02 01:44:14 +00:00
|
|
|
media {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
2020-09-08 00:20:15 +00:00
|
|
|
lazy
|
2020-08-02 01:44:14 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-01 13:11:07 +00:00
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
limit,
|
|
|
|
offset: Math.max(0, (pageNumber - 1)) * limit,
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
|
|
|
movies: movies.map(release => curateRelease(release)),
|
|
|
|
totalCount,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2020-08-12 01:30:20 +00:00
|
|
|
async function fetchMovieById({ _commit }, movieId) {
|
|
|
|
// const release = await get(`/releases/${releaseId}`);
|
|
|
|
|
|
|
|
const { movie } = await graphql(`
|
|
|
|
query Movie($movieId: Int!) {
|
|
|
|
movie(id: $movieId) {
|
|
|
|
id
|
|
|
|
title
|
|
|
|
slug
|
|
|
|
url
|
|
|
|
date
|
|
|
|
actors {
|
|
|
|
id
|
|
|
|
name
|
2020-09-08 00:20:15 +00:00
|
|
|
slug
|
2020-08-12 01:30:20 +00:00
|
|
|
age
|
|
|
|
dateOfBirth
|
|
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
|
|
alpha2
|
|
|
|
name
|
|
|
|
alias
|
|
|
|
}
|
|
|
|
avatar: avatarMedia {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
|
|
|
}
|
|
|
|
}
|
2020-08-20 02:57:38 +00:00
|
|
|
covers: moviesCovers {
|
2020-08-12 01:30:20 +00:00
|
|
|
media {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
2020-09-08 00:20:15 +00:00
|
|
|
lazy
|
2020-08-12 01:30:20 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-20 02:57:38 +00:00
|
|
|
trailer: moviesTrailerByMovieId {
|
2020-08-12 01:30:20 +00:00
|
|
|
media {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scenes: moviesScenes {
|
|
|
|
scene {
|
|
|
|
${releaseFields}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tags {
|
|
|
|
id
|
|
|
|
slug
|
|
|
|
name
|
|
|
|
}
|
2020-09-08 00:20:15 +00:00
|
|
|
photos {
|
|
|
|
id
|
|
|
|
index
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
|
|
|
comment
|
|
|
|
sfw: sfwMedia {
|
|
|
|
id
|
|
|
|
thumbnail
|
|
|
|
lazy
|
|
|
|
path
|
|
|
|
comment
|
|
|
|
}
|
|
|
|
}
|
2020-08-12 01:30:20 +00:00
|
|
|
entity {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
type
|
|
|
|
parent {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
type
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
movieId: Number(movieId),
|
|
|
|
});
|
|
|
|
|
|
|
|
return curateRelease(movie);
|
|
|
|
}
|
|
|
|
|
2020-05-14 02:26:05 +00:00
|
|
|
return {
|
|
|
|
fetchReleases,
|
|
|
|
fetchReleaseById,
|
2020-08-01 13:11:07 +00:00
|
|
|
fetchMovies,
|
2020-08-12 01:30:20 +00:00
|
|
|
fetchMovieById,
|
2020-05-14 02:26:05 +00:00
|
|
|
};
|
2019-06-03 03:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default initReleasesActions;
|