2019-12-15 21:16:55 +00:00
|
|
|
import { graphql } from '../api';
|
2021-08-21 23:26:09 +00:00
|
|
|
import {
|
|
|
|
releasesFragment,
|
|
|
|
releaseFragment,
|
|
|
|
releaseFields,
|
|
|
|
movieFields,
|
|
|
|
} 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(
|
2021-03-19 02:27:48 +00:00
|
|
|
$hasAuth: Boolean!
|
|
|
|
$userId: Int
|
2019-12-18 01:42:55 +00:00
|
|
|
$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
|
|
|
`, {
|
2021-03-19 02:27:48 +00:00
|
|
|
hasAuth: !!store.state.auth.user,
|
|
|
|
userId: store.state.auth.user?.id,
|
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 {
|
2021-11-20 22:59:15 +00:00
|
|
|
releases: releases.map((release) => curateRelease(release)),
|
2020-05-22 02:32:16 +00:00
|
|
|
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(`
|
2021-03-17 01:09:34 +00:00
|
|
|
query Release(
|
|
|
|
$releaseId: Int!
|
|
|
|
$hasAuth: Boolean!
|
|
|
|
$userId: 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),
|
2021-03-17 01:09:34 +00:00
|
|
|
hasAuth: !!store.state.auth.user,
|
|
|
|
userId: store.state.auth.user?.id,
|
2020-05-14 02:26:05 +00:00
|
|
|
});
|
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,
|
2021-09-11 22:05:45 +00:00
|
|
|
$hasAuth: Boolean!
|
|
|
|
$userId: Int
|
2020-08-01 13:11:07 +00:00
|
|
|
) {
|
|
|
|
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 {
|
2021-08-21 22:40:22 +00:00
|
|
|
${movieFields}
|
2020-08-01 13:11:07 +00:00
|
|
|
}
|
|
|
|
totalCount
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
2021-09-11 22:05:45 +00:00
|
|
|
hasAuth: !!store.state.auth.user,
|
|
|
|
userId: store.state.auth.user?.id,
|
2020-08-01 13:11:07 +00:00
|
|
|
limit,
|
|
|
|
offset: Math.max(0, (pageNumber - 1)) * limit,
|
|
|
|
});
|
|
|
|
|
|
|
|
return {
|
2021-11-20 22:59:15 +00:00
|
|
|
movies: movies.map((release) => curateRelease(release)),
|
2020-08-01 13:11:07 +00:00
|
|
|
totalCount,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-08-22 20:25:20 +00:00
|
|
|
async function searchMovies({ _commit }, { query, limit = 20, pageNumber = 1 }) {
|
|
|
|
const { connection: { movies, totalCount } } = await graphql(`
|
2021-08-21 22:40:22 +00:00
|
|
|
query SearchMovies(
|
|
|
|
$query: String!
|
2021-08-22 20:25:20 +00:00
|
|
|
$limit:Int = 20
|
|
|
|
$offset:Int = 0
|
2021-08-21 22:40:22 +00:00
|
|
|
) {
|
2021-08-22 20:25:20 +00:00
|
|
|
connection: searchMoviesConnection(
|
2021-08-21 22:40:22 +00:00
|
|
|
query: $query
|
|
|
|
first: $limit
|
2021-08-22 20:25:20 +00:00
|
|
|
offset: $offset
|
|
|
|
orderBy: RANK_DESC
|
2021-08-21 22:40:22 +00:00
|
|
|
) {
|
2021-08-22 20:25:20 +00:00
|
|
|
movies: nodes {
|
|
|
|
movie {
|
|
|
|
${movieFields}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
totalCount
|
2021-08-21 22:40:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
query,
|
|
|
|
limit,
|
2021-08-22 20:25:20 +00:00
|
|
|
offset: Math.max(0, (pageNumber - 1)) * limit,
|
2021-08-21 22:40:22 +00:00
|
|
|
});
|
|
|
|
|
2021-08-22 20:25:20 +00:00
|
|
|
return {
|
|
|
|
movies: movies.map(({ movie }) => curateRelease(movie)),
|
|
|
|
totalCount,
|
|
|
|
};
|
2021-08-21 22:40:22 +00:00
|
|
|
}
|
|
|
|
|
2020-08-12 01:30:20 +00:00
|
|
|
async function fetchMovieById({ _commit }, movieId) {
|
|
|
|
// const release = await get(`/releases/${releaseId}`);
|
|
|
|
|
|
|
|
const { movie } = await graphql(`
|
2021-03-17 04:11:17 +00:00
|
|
|
query Movie(
|
|
|
|
$movieId: Int!
|
|
|
|
$hasAuth: Boolean!
|
|
|
|
$userId: Int
|
|
|
|
) {
|
2020-08-12 01:30:20 +00:00
|
|
|
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
|
2021-03-18 03:36:04 +00:00
|
|
|
width
|
|
|
|
height
|
|
|
|
thumbnailWidth
|
|
|
|
thumbnailHeight
|
2020-08-12 01:30:20 +00:00
|
|
|
lazy
|
2021-02-23 00:30:38 +00:00
|
|
|
isS3
|
|
|
|
}
|
|
|
|
}
|
2021-12-05 01:54:55 +00:00
|
|
|
poster: moviesPoster {
|
2021-02-23 00:30:38 +00:00
|
|
|
media {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
|
|
|
lazy
|
2021-03-18 03:36:04 +00:00
|
|
|
width
|
|
|
|
height
|
|
|
|
thumbnailWidth
|
|
|
|
thumbnailHeight
|
2021-02-23 00:30:38 +00:00
|
|
|
isS3
|
2020-08-12 01:30:20 +00:00
|
|
|
}
|
|
|
|
}
|
2022-01-29 22:39:12 +00:00
|
|
|
covers: moviesCovers(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
|
2020-08-12 01:30:20 +00:00
|
|
|
media {
|
|
|
|
id
|
|
|
|
path
|
|
|
|
thumbnail
|
2021-03-18 03:36:04 +00:00
|
|
|
width
|
|
|
|
height
|
|
|
|
thumbnailWidth
|
|
|
|
thumbnailHeight
|
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
|
|
|
}
|
|
|
|
}
|
2021-12-05 01:54:55 +00:00
|
|
|
trailer: moviesTrailer {
|
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-03-18 03:36:04 +00:00
|
|
|
width
|
|
|
|
height
|
|
|
|
thumbnailWidth
|
|
|
|
thumbnailHeight
|
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
|
|
|
}
|
|
|
|
}
|
2021-03-17 04:11:17 +00:00
|
|
|
stashes: stashesMovies(
|
|
|
|
filter: {
|
|
|
|
stash: {
|
|
|
|
userId: {
|
|
|
|
equalTo: $userId
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
) @include(if: $hasAuth) {
|
|
|
|
stash {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
2021-03-21 02:58:13 +00:00
|
|
|
primary
|
2021-03-17 04:11:17 +00:00
|
|
|
}
|
|
|
|
}
|
2020-08-12 01:30:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
movieId: Number(movieId),
|
2021-03-17 04:11:17 +00:00
|
|
|
hasAuth: !!store.state.auth.user,
|
|
|
|
userId: store.state.auth.user?.id,
|
2020-08-12 01:30:20 +00:00
|
|
|
});
|
|
|
|
|
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,
|
2021-08-21 22:40:22 +00:00
|
|
|
searchMovies,
|
2020-05-14 02:26:05 +00:00
|
|
|
};
|
2019-06-03 03:31:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default initReleasesActions;
|