traxxx/assets/js/fragments.js

405 lines
6.2 KiB
JavaScript

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 actorFields = `
id
name
slug
birthdate: dateOfBirth
age
ageFromBirth
dateOfBirth
gender
avatar: avatarMedia {
id
path
thumbnail
lazy
sfw: sfwMedia {
id
path
thumbnail
lazy
}
}
entity {
id
name
slug
}
birthCountry: countryByBirthCountryAlpha2 {
alpha2
name
alias
}
`;
const releaseActorsFragment = `
actors: releasesActors(orderBy: ACTOR_BY_ACTOR_ID__GENDER_ASC) {
actor {
${actorFields}
}
}
`;
const releaseTagsFragment = `
tags: releasesTags(orderBy: TAG_BY_TAG_ID__PRIORITY_DESC) {
tag {
name
priority
slug
id
}
}
`;
const releasePosterFragment = `
poster: releasesPosterByReleaseId {
media {
id
index
path
thumbnail
lazy
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
`;
const releaseCoversFragment = `
covers: releasesCovers(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
media {
id
index
path
thumbnail
lazy
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
`;
const releasePhotosFragment = `
photos: releasesPhotos(orderBy: MEDIA_BY_MEDIA_ID__INDEX_ASC) {
media {
id
index
path
thumbnail
lazy
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
`;
const releaseTrailerFragment = `
trailer: releasesTrailerByReleaseId {
media {
id
index
path
thumbnail
mime
isVr
}
}
`;
const releaseTeaserFragment = `
teaser: releasesTeaserByReleaseId {
media {
id
index
path
thumbnail
mime
}
}
`;
const releaseFields = `
id
title
date
datePrecision
slug
shootId
productionDate
comment
createdAt
url
createdBatchId
${releaseActorsFragment}
${releaseTagsFragment}
${releasePosterFragment}
${releaseCoversFragment}
${releasePhotosFragment}
${siteFragment}
studio {
id
name
slug
url
}
isNew
`;
const releasesFragment = `
connection: releasesConnection(
filter: {
date: {
lessThan: $before,
greaterThan: $after,
}
releasesTagsConnection: {
none: {
tag: {
slug: {
in: $exclude
}
}
}
}
},
first: $limit,
offset: $offset,
orderBy: $orderBy,
) {
releases: nodes {
${releaseFields}
}
totalCount
}
`;
const releaseFragment = `
release(id: $releaseId) {
id
title
description
date
datePrecision
duration
createdAt
shootId
productionDate
createdBatchId
productionLocation
productionCity
productionState
productionCountry: countryByProductionCountryAlpha2 {
alpha2
name
alias
}
comment
url
${releaseActorsFragment}
${releaseTagsFragment}
${releasePosterFragment}
${releasePhotosFragment}
${releaseCoversFragment}
${releaseTrailerFragment}
${releaseTeaserFragment}
${siteFragment}
clips {
id
title
description
duration
tags: clipsTags {
tag {
id
name
slug
}
}
poster: clipsPosterByClipId {
media {
id
index
path
thumbnail
lazy
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
}
studio {
id
name
slug
url
}
movies: moviesScenesBySceneId {
movie {
id
title
slug
covers: moviesCovers {
media {
id
index
path
thumbnail
lazy
comment
sfw: sfwMedia {
id
thumbnail
lazy
path
comment
}
}
}
}
}
}
`;
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 {
releaseActorsFragment,
releaseFields,
releaseTagsFragment,
releasePosterFragment,
releasePhotosFragment,
releaseTrailerFragment,
releasesFragment,
releaseFragment,
siteFragment,
sitesFragment,
getIncludedEntities,
getIncludedActors,
};