traxxx/assets/js/fragments.js

717 lines
9.7 KiB
JavaScript
Executable File

const siteFragment = `
entity {
id
name
slug
url
type
independent
hasLogo
parent {
id
name
slug
url
type
independent
hasLogo
}
}
`;
const sitesFragment = `
entities {
id
name
slug
url
type
independent
hasLogo
parent {
id
name
slug
url
type
independent
hasLogo
}
}
`;
const actorStashesFields = `
isStashed
isFavorited
stashes: stashesActors(
filter: {
stash: {
userId: {
equalTo: $userId
}
}
}
) @include(if: $hasAuth) {
stash {
id
name
slug
primary
}
}
`;
const actorFields = `
id
name
slug
birthdate: dateOfBirth
age
ageFromBirth
dateOfBirth
gender
orientation
avatar: avatarMedia {
id
path
thumbnail
lazy
isS3
sfw: sfwMedia {
id
path
thumbnail
lazy
}
}
entity {
id
name
slug
}
birthCountry: countryByBirthCountryAlpha2 {
alpha2
name
alias
}
${actorStashesFields}
`;
const movieFields = `
id
title
url
slug
date
datePrecision
actors {
id
name
slug
}
tags {
id
name
slug
}
entity {
id
name
slug
type
parent {
id
name
slug
type
}
}
covers: moviesCovers(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
media {
id
path
thumbnail
lazy
width
height
thumbnailWidth
thumbnailHeight
isS3
sfw: sfwMedia {
id
path
thumbnail
lazy
comment
}
}
}
isFavorited
isStashed(includeFavorites: false)
stashes: stashesMovies(
filter: {
stash: {
userId: {
equalTo: $userId
}
}
}
) @include(if: $hasAuth) {
stash {
id
name
slug
primary
}
}
`;
const campaignFields = `
id
url
affiliate {
id
url
parameters
}
banner {
id
type
width
height
ratio
entity {
id
type
name
slug
parent {
id
type
name
slug
}
}
}
entity {
id
type
name
slug
parent {
id
type
name
slug
}
}
`;
const campaignsFragment = `
campaigns(filter: {
or: [
{
banner: {
bannersTagsConnection: {
none: {
tag: {
slug: {
in: $exclude
}
}
}
}
}
}
{
bannerExists: false
}
]
}) {
${campaignFields}
}
`;
const releaseActorsFragment = `
actors: releasesActors(orderBy: ACTOR_BY_ACTOR_ID__GENDER_ASC) {
actor {
${actorFields}
}
}
`;
const releaseDirectorFragment = `
directors: releasesDirectors(orderBy: ACTOR_BY_DIRECTOR_ID__NAME_ASC) {
director {
${actorFields}
}
}
`;
const releaseTagsFragment = `
tags: releasesTags(
orderBy: TAG_BY_TAG_ID__PRIORITY_DESC
filter: {
tagId: { isNull: false }
}
) {
tag {
name
priority
slug
id
}
}
`;
const releasePosterFragment = `
poster: releasesPoster {
media {
id
index
path
thumbnail
width
height
thumbnailWidth
thumbnailHeight
lazy
isS3
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
`;
const releaseCoversFragment = `
covers: releasesCovers(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
media {
id
index
path
thumbnail
width
height
thumbnailWidth
thumbnailHeight
lazy
isS3
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
`;
const releasePhotosFragment = `
photos: releasesPhotos(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
media {
id
index
path
thumbnail
width
height
thumbnailWidth
thumbnailHeight
lazy
isS3
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
`;
const releaseTrailerFragment = `
trailer: releasesTrailer {
media {
id
index
path
thumbnail
mime
isS3
isVr
}
}
`;
const releaseTeaserFragment = `
teaser: releasesTeaser {
media {
id
index
path
thumbnail
mime
isS3
}
}
`;
const releaseFields = `
id
title
date
datePrecision
slug
qualities
shootId
productionDate
comment
createdAt
url
createdBatchId
${releaseActorsFragment}
${releaseTagsFragment}
${releasePosterFragment}
${releaseCoversFragment}
${releasePhotosFragment}
${siteFragment}
studio {
id
name
slug
url
}
movies: moviesScenesBySceneId {
movie {
id
title
slug
}
}
isFavorited
isStashed(includeFavorites: false)
stashes: stashesScenesBySceneId(
filter: {
stash: {
userId: {
equalTo: $userId
}
}
}
) @include(if: $hasAuth) {
stash {
id
name
slug
primary
}
}
`;
// isNew too performance-intensive
/*
const releasesFragment = `
connection: releasesConnection(
filter: {
releasesNotShowcasedsConnectionExist: false
effectiveDate: {
lessThan: $before,
greaterThan: $after
}
releasesTagsConnection: {
none: {
tag: {
slug: {
in: $exclude
}
}
}
}
},
first: $limit,
offset: $offset,
orderBy: $orderBy
) {
releases: nodes {
${releaseFields}
}
totalCount
}
`;
*/
const releasesFragment = `
connection: releasesSummariesConnection(
first: $limit
offset: $offset
orderBy: $orderBy
filter: {
not: { tags: { overlaps: $exclude } }
effectiveDate: { lessThan: $before, greaterThan: $after }
showcased: { equalTo: true }
}
) {
releases: nodes {
release {
${releaseFields}
}
}
totalCount
}
`;
const mediaFields = `
id
index
path
thumbnail
lazy
isS3
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
`;
const mediaFragment = `
media {
${mediaFields}
}
`;
const releaseFragment = `
release(id: $releaseId) {
id
title
description
date
datePrecision
duration
createdAt
shootId
qualities
productionDate
createdBatchId
productionLocation
productionCity
productionState
productionCountry: countryByProductionCountryAlpha2 {
alpha2
name
alias
}
comment
url
${releaseActorsFragment}
${releaseDirectorFragment}
${releaseTagsFragment}
${releasePosterFragment}
${releasePhotosFragment}
${releaseCoversFragment}
${releaseTrailerFragment}
${releaseTeaserFragment}
${siteFragment}
chapters(orderBy: TIME_ASC) {
id
index
time
duration
title
description
tags: chaptersTags {
tag {
id
name
slug
}
}
poster: chaptersPoster {
media {
id
index
path
thumbnail
lazy
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
}
studio {
id
name
slug
url
showcased
}
movies: moviesScenesBySceneId {
movie {
id
title
slug
covers: moviesCovers(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
media {
id
index
path
thumbnail
lazy
isS3
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
}
}
series: seriesScenesBySceneId {
serie {
id
title
slug
covers: seriesCoversBySerieId(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
${mediaFragment}
}
poster: seriesPosterBySerieId {
${mediaFragment}
}
}
}
isFavorited
isStashed(includeFavorites: false)
stashes: stashesScenesBySceneId(
filter: {
stash: {
userId: {
equalTo: $userId
}
}
}
) @include(if: $hasAuth) {
stash {
id
name
slug
primary
}
}
}
`;
const batchFragment = `
batches(first: 1, orderBy: CREATED_AT_DESC) {
id
}
`;
function getIncludedEntities(router) {
const includedChannels = router.currentRoute.value.query.channels ? router.currentRoute.value.query.channels.split(',') : [];
const includedNetworks = router.currentRoute.value.query.networks ? router.currentRoute.value.query.networks.split(',') : [];
if (includedChannels.length === 0 && includedNetworks.length === 0) {
return [];
}
return [
{
entity: {
slug: {
in: includedChannels,
},
},
},
{
entity: {
parent: {
type: {
equalTo: 'network',
},
slug: {
in: includedNetworks,
},
},
},
},
{
entity: {
type: {
equalTo: 'network',
},
slug: {
in: includedNetworks,
},
},
},
];
}
function getIncludedActors(router) {
const includedActors = router.currentRoute.value.query.actors ? router.currentRoute.value.query.actors.split(',') : [];
if (includedActors.length === 0) {
return [];
}
return [
{
releasesActorsConnection: {
some: {
actor: {
slug: {
in: includedActors,
},
},
},
},
},
];
}
export {
actorFields,
actorStashesFields,
batchFragment,
campaignFields,
campaignsFragment,
mediaFields,
mediaFragment,
movieFields,
releaseActorsFragment,
releaseFields,
releaseTagsFragment,
releasePosterFragment,
releasePhotosFragment,
releaseTrailerFragment,
releasesFragment,
releaseFragment,
siteFragment,
sitesFragment,
getIncludedEntities,
getIncludedActors,
};