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
|
|
|
|
2020-09-10 01:17:19 +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,
|
2021-01-03 21:53:51 +00:00
|
|
|
exclude: store.state.ui.tagFilter,
|
2020-05-14 02:26:05 +00:00
|
|
|
});
|
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-09-10 01:17:19 +00:00
|
|
|
if (!release) {
|
|
|
|
router.replace('/not-found');
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
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
|
2021-02-02 03:03:36 +00:00
|
|
|
filter: {
|
|
|
|
date: {
|
|
|
|
isNull: false
|
|
|
|
}
|
|
|
|
}
|
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
|
2021-02-23 00:30:38 +00:00
|
|
|
isS3
|
2020-12-27 22:10:11 +00:00
|
|
|
sfw: sfwMedia {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
|
|
|
comment
|
|
|
|
}
|
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
|
2021-01-25 22:01:07 +00:00
|
|
|
description
|
2020-08-12 01:30:20 +00:00
|
|
|
slug
|
|
|
|
url
|
|
|
|
date
|
2021-02-02 03:00:01 +00:00
|
|
|
createdBatchId
|
2020-08-12 01:30:20 +00:00
|
|
|
actors {
|
|
|
|
id
|
|
|
|
name
|
2020-09-08 00:20:15 +00:00
|
|
|
slug
|
2020-08-12 01:30:20 +00:00
|
|
|
age
|
2020-12-17 02:48:38 +00:00
|
|
|
ageFromBirth
|
2020-08-12 01:30:20 +00:00
|
|
|
dateOfBirth
|
|
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
|
|
alpha2
|
|
|
|
name
|
|
|
|
alias
|
|
|
|
}
|
|
|
|
avatar: avatarMedia {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
2021-02-23 00:30:38 +00:00
|
|
|
isS3
|
|
|
|
}
|
|
|
|
}
|
|
|
|
posters: moviesPosterByMovieId {
|
|
|
|
media {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
|
|
|
isS3
|
2020-08-12 01:30:20 +00:00
|
|
|
}
|
|
|
|
}
|
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
|
2021-02-23 00:30:38 +00:00
|
|
|
isS3
|
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
|
2021-02-23 00:30:38 +00:00
|
|
|
isS3
|
2020-08-12 01:30:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
scenes: moviesScenes {
|
|
|
|
scene {
|
|
|
|
${releaseFields}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tags {
|
|
|
|
id
|
|
|
|
slug
|
|
|
|
name
|
|
|
|
}
|
2020-09-08 00:20:15 +00:00
|
|
|
photos {
|
|
|
|
id
|
|
|
|
index
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
2021-02-23 00:30:38 +00:00
|
|
|
isS3
|
2020-09-08 00:20:15 +00:00
|
|
|
comment
|
|
|
|
sfw: sfwMedia {
|
|
|
|
id
|
|
|
|
thumbnail
|
|
|
|
lazy
|
|
|
|
path
|
|
|
|
comment
|
|
|
|
}
|
|
|
|
}
|
2020-08-12 01:30:20 +00:00
|
|
|
entity {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
type
|
2021-02-02 02:52:15 +00:00
|
|
|
hasLogo
|
2020-08-12 01:30:20 +00:00
|
|
|
parent {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
type
|
2021-02-02 02:52:15 +00:00
|
|
|
hasLogo
|
2020-08-12 01:30:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
movieId: Number(movieId),
|
|
|
|
});
|
|
|
|
|
2020-09-10 01:17:19 +00:00
|
|
|
if (!movie) {
|
|
|
|
router.replace('/not-found');
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2020-08-12 01:30:20 +00:00
|
|
|
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;
|