2019-12-15 21:16:55 +00:00
|
|
|
import { graphql } from '../api';
|
2021-08-21 23:26:09 +00:00
|
|
|
import {
|
2023-06-15 22:47:19 +00:00
|
|
|
batchFragment,
|
2021-08-21 23:26:09 +00:00
|
|
|
releasesFragment,
|
|
|
|
releaseFragment,
|
|
|
|
releaseFields,
|
|
|
|
movieFields,
|
2022-03-27 21:42:03 +00:00
|
|
|
mediaFragment,
|
|
|
|
mediaFields,
|
2021-08-21 23:26:09 +00:00
|
|
|
} 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
|
|
|
|
2023-06-15 22:47:19 +00:00
|
|
|
const { connection: { releases, totalCount }, batches: [lastBatch] } = 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",
|
2023-07-16 23:59:26 +00:00
|
|
|
$orderBy: [ReleasesSummariesOrderBy!],
|
2023-07-25 02:23:10 +00:00
|
|
|
$exclude: [String!],
|
|
|
|
$batchShowcased: [Boolean!]
|
2019-12-18 01:42:55 +00:00
|
|
|
) {
|
2019-12-16 04:30:25 +00:00
|
|
|
${releasesFragment}
|
2023-06-15 22:47:19 +00:00
|
|
|
${batchFragment}
|
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,
|
2023-01-16 15:49:47 +00:00
|
|
|
orderBy,
|
2021-01-03 21:53:51 +00:00
|
|
|
exclude: store.state.ui.tagFilter,
|
2023-07-25 02:23:10 +00:00
|
|
|
batchShowcased: range === 'new' ? true : [true, false],
|
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 {
|
2023-06-15 22:47:19 +00:00
|
|
|
releases: releases.map((release) => curateRelease(release.release || release, 'scene', { lastBatch: lastBatch.id })),
|
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
|
2023-07-02 03:07:38 +00:00
|
|
|
orderBy: EFFECTIVE_DATE_DESC
|
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
|
2022-02-02 23:04:48 +00:00
|
|
|
$hasAuth: Boolean!
|
|
|
|
$userId: Int
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
2022-02-02 23:04:48 +00:00
|
|
|
hasAuth: !!store.state.auth.user,
|
|
|
|
userId: store.state.auth.user?.id,
|
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
|
|
|
}
|
|
|
|
|
2022-03-26 16:40:20 +00:00
|
|
|
async function fetchCollectionById({ _commit }, movieId, type = 'movie') {
|
2020-08-12 01:30:20 +00:00
|
|
|
// const release = await get(`/releases/${releaseId}`);
|
|
|
|
|
2022-03-26 16:40:20 +00:00
|
|
|
const result = await graphql(`
|
2021-03-17 04:11:17 +00:00
|
|
|
query Movie(
|
|
|
|
$movieId: Int!
|
|
|
|
$hasAuth: Boolean!
|
|
|
|
$userId: Int
|
|
|
|
) {
|
2022-03-26 16:40:20 +00:00
|
|
|
${type}(id: $movieId) {
|
2020-08-12 01:30:20 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
2022-03-26 16:40:20 +00:00
|
|
|
poster: ${type === 'series' ? 'seriesPosterBySerieId' : '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-03-26 16:40:20 +00:00
|
|
|
covers: ${type === 'series' ? 'seriesCoversBySerieId' : '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
|
|
|
}
|
|
|
|
}
|
2022-03-26 16:40:20 +00:00
|
|
|
trailer: ${type === 'series' ? 'seriesTrailerBySerieId' : '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
|
|
|
}
|
|
|
|
}
|
2022-03-26 16:40:20 +00:00
|
|
|
scenes: ${type === 'series' ? 'seriesScenesBySerieId' : 'moviesScenes'} {
|
2020-08-12 01:30:20 +00:00
|
|
|
scene {
|
|
|
|
${releaseFields}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
tags {
|
|
|
|
id
|
|
|
|
slug
|
|
|
|
name
|
|
|
|
}
|
2022-03-27 22:22:57 +00:00
|
|
|
photos: ${type === 'series' ? 'seriesPhotosBySerieId' : 'moviesPhotos'} {
|
2022-03-27 21:42:03 +00:00
|
|
|
${mediaFragment}
|
|
|
|
}
|
|
|
|
scenesPhotos {
|
|
|
|
${mediaFields}
|
2020-09-08 00:20:15 +00:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2022-03-26 16:40:20 +00:00
|
|
|
stashes: ${type === 'series' ? 'stashesSeriesBySerieId' : 'stashesMovies'}(
|
2021-03-17 04:11:17 +00:00
|
|
|
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
|
|
|
});
|
|
|
|
|
2022-03-26 16:40:20 +00:00
|
|
|
if (!result[type]) {
|
2020-09-10 01:17:19 +00:00
|
|
|
router.replace('/not-found');
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2022-03-26 16:40:20 +00:00
|
|
|
return curateRelease(result[type]);
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchMovieById(context, movieId) {
|
|
|
|
return fetchCollectionById(context, movieId, 'movie');
|
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchSerieById(context, serieId) {
|
|
|
|
return fetchCollectionById(context, serieId, 'series');
|
2020-08-12 01:30:20 +00:00
|
|
|
}
|
|
|
|
|
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,
|
2022-03-26 16:40:20 +00:00
|
|
|
fetchSerieById,
|
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;
|