traxxx/assets/js/fragments.js

772 lines
11 KiB
JavaScript
Raw Normal View History

const siteFragment = `
entity {
id
name
slug
url
type
independent
hasLogo
parent {
id
name
slug
url
type
independent
hasLogo
}
}
`;
2020-01-02 23:59:02 +00:00
const sitesFragment = `
entities {
2020-01-02 23:59:02 +00:00
id
name
slug
url
type
independent
hasLogo
parent {
2020-01-02 23:59:02 +00:00
id
name
slug
url
type
independent
hasLogo
2020-01-02 23:59:02 +00:00
}
}
`;
2021-03-24 00:52:27 +00:00
const actorStashesFields = `
isStashed
isFavorited
stashes: stashesActors(
filter: {
stash: {
userId: {
equalTo: $userId
}
}
}
) @include(if: $hasAuth) {
stash {
id
name
slug
primary
}
}
`;
2020-03-09 04:06:37 +00:00
const actorFields = `
id
name
slug
2020-05-15 02:40:59 +00:00
birthdate: dateOfBirth
age
2020-12-17 02:48:38 +00:00
ageFromBirth
dateOfBirth
2020-01-25 01:29:49 +00:00
gender
orientation
avatar: avatarMedia {
id
path
thumbnail
lazy
2021-02-24 02:56:20 +00:00
isS3
2020-05-25 00:02:28 +00:00
sfw: sfwMedia {
id
path
thumbnail
lazy
}
}
entity {
id
name
slug
}
birthCountry: countryByBirthCountryAlpha2 {
alpha2
name
alias
}
2021-03-24 00:52:27 +00:00
${actorStashesFields}
2020-03-09 04:06:37 +00:00
`;
const basicActorFields = `
id
name
slug
gender
`;
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
}
}
`;
2023-07-05 22:14:38 +00:00
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
}
]
}) {
2023-07-05 22:14:38 +00:00
${campaignFields}
}
`;
2020-03-09 04:06:37 +00:00
const releaseActorsFragment = `
actors: releasesActors(orderBy: ACTOR_BY_ACTOR_ID__GENDER_ASC) {
actor {
${actorFields}
}
}
`;
const releaseBasicActorsFragment = `
actors: releasesActors(orderBy: ACTOR_BY_ACTOR_ID__GENDER_ASC) {
actor {
${basicActorFields}
}
}
`;
2021-03-06 23:01:02 +00:00
const releaseDirectorFragment = `
directors: releasesDirectors(orderBy: ACTOR_BY_DIRECTOR_ID__NAME_ASC) {
director {
${actorFields}
}
}
`;
const releaseTagsFragment = `
2021-10-09 22:04:21 +00:00
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 releaseCapsFragment = `
caps: releasesCaps(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
${releaseBasicActorsFragment}
${releaseTagsFragment}
${releasePosterFragment}
${releasePhotosFragment}
${releaseCapsFragment}
${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 = `
2023-01-16 15:49:47 +00:00
connection: releasesConnection(
2019-12-18 01:42:55 +00:00
filter: {
2023-01-16 20:32:22 +00:00
releasesNotShowcasedsConnectionExist: false
2023-07-02 20:21:19 +00:00
effectiveDate: {
2023-01-16 15:49:47 +00:00
lessThan: $before,
greaterThan: $after
}
releasesTagsConnection: {
none: {
tag: {
2023-06-17 21:31:09 +00:00
slug: {
in: $exclude
}
}
}
2023-01-14 22:44:32 +00:00
}
2019-12-18 01:42:55 +00:00
},
first: $limit,
2020-05-22 02:32:16 +00:00
offset: $offset,
2023-01-14 22:44:32 +00:00
orderBy: $orderBy
2019-12-18 01:42:55 +00:00
) {
2020-05-22 02:32:16 +00:00
releases: nodes {
2023-01-16 15:49:47 +00:00
${releaseFields}
2020-05-22 02:32:16 +00:00
}
totalCount
2019-12-18 01:42:55 +00:00
}
`;
*/
const releasesFragment = `
connection: releasesSummariesConnection(
first: $limit
offset: $offset
orderBy: $orderBy
filter: {
or: [
{
not: { tags: { overlaps: $exclude } }
}
{
tags: { isNull: true }
}
]
effectiveDate: { lessThan: $before, greaterThan: $after }
showcased: { equalTo: true }
batchShowcased: { in: $batchShowcased }
}
) {
releases: nodes {
release {
${releaseFields}
}
}
totalCount
}
`;
const mediaFields = `
id
index
path
thumbnail
lazy
isS3
comment
sfw: sfwMedia {
2022-03-26 16:40:20 +00:00
id
thumbnail
lazy
path
2022-03-26 16:40:20 +00:00
comment
}
`;
const mediaFragment = `
media {
${mediaFields}
2022-03-26 16:40:20 +00:00
}
`;
const releaseFragment = `
release(id: $releaseId) {
id
title
altTitles
description
date
datePrecision
duration
createdAt
shootId
qualities
2023-11-07 03:46:45 +00:00
photoCount
productionDate
createdBatchId
productionLocation
productionCity
productionState
productionCountry: countryByProductionCountryAlpha2 {
alpha2
name
alias
}
comment
url
${releaseActorsFragment}
2021-03-06 23:01:02 +00:00
${releaseDirectorFragment}
${releaseTagsFragment}
${releasePosterFragment}
${releasePhotosFragment}
${releaseCapsFragment}
${releaseCoversFragment}
${releaseTrailerFragment}
${releaseTeaserFragment}
${siteFragment}
chapters(orderBy: TIME_ASC) {
id
2021-02-26 23:37:22 +00:00
index
time
duration
title
description
2021-02-26 23:37:22 +00:00
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
2023-06-18 00:12:13 +00:00
showcased
}
movies: moviesScenesBySceneId {
movie {
id
title
slug
covers: moviesCovers(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
media {
id
index
path
thumbnail
lazy
2021-02-23 00:30:38 +00:00
isS3
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
}
}
2022-03-26 16:40:20 +00:00
series: seriesScenesBySceneId {
serie {
id
title
slug
covers: seriesCoversBySerieId(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
${mediaFragment}
}
poster: seriesPosterBySerieId {
${mediaFragment}
}
}
}
isFavorited
isStashed(includeFavorites: false)
2021-03-17 01:09:34 +00:00
stashes: stashesScenesBySceneId(
filter: {
stash: {
userId: {
equalTo: $userId
}
}
}
) @include(if: $hasAuth) {
stash {
id
name
slug
primary
2021-03-17 01:09:34 +00:00
}
}
}
`;
2023-06-15 22:47:19 +00:00
const batchFragment = `
batches(
first: 1,
orderBy: CREATED_AT_DESC,
filter: { showcased: { equalTo: true } }
) {
2023-06-15 22:47:19 +00:00
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,
2021-03-24 00:52:27 +00:00
actorStashesFields,
2023-06-15 22:47:19 +00:00
batchFragment,
2023-07-05 22:14:38 +00:00
campaignFields,
campaignsFragment,
mediaFields,
mediaFragment,
movieFields,
releaseActorsFragment,
releaseFields,
releaseTagsFragment,
releasePosterFragment,
releasePhotosFragment,
releaseTrailerFragment,
releasesFragment,
releaseFragment,
siteFragment,
sitesFragment,
getIncludedEntities,
getIncludedActors,
};