314 lines
6.8 KiB
JavaScript
314 lines
6.8 KiB
JavaScript
import config from 'config';
|
|
import { graphql, get } from '../api';
|
|
import { releaseFields, getIncludedEntities } from '../fragments';
|
|
import { curateActor, curateRelease } from '../curate';
|
|
import getDateRange from '../get-date-range';
|
|
|
|
function initActorActions(store, router) {
|
|
async function fetchActorById({ _commit }, {
|
|
actorId,
|
|
limit = 10,
|
|
pageNumber = 1,
|
|
range = 'latest',
|
|
}) {
|
|
const { before, after, orderBy } = getDateRange(range);
|
|
const includedTags = router.currentRoute.query.tags ? router.currentRoute.query.tags.split(',') : [];
|
|
const mode = router.currentRoute.query.mode || 'all';
|
|
|
|
const { actor } = await graphql(`
|
|
query Actor(
|
|
$actorId: Int!
|
|
$limit:Int = 10,
|
|
$offset:Int = 0,
|
|
$after:Datetime = "1900-01-01",
|
|
$before:Datetime = "2100-01-01",
|
|
$orderBy:[ReleasesOrderBy!]
|
|
$selectableTags: [String],
|
|
$includedTags: [String!],
|
|
$mode: String!,
|
|
$includedEntities: [ReleaseFilter!]
|
|
) {
|
|
actor(id: $actorId) {
|
|
id
|
|
name
|
|
slug
|
|
realName
|
|
gender
|
|
dateOfBirth
|
|
dateOfDeath
|
|
age
|
|
ageAtDeath
|
|
ethnicity
|
|
cup
|
|
bust
|
|
waist
|
|
hip
|
|
naturalBoobs
|
|
heightMetric: height(units:METRIC)
|
|
heightImperial: height(units:IMPERIAL)
|
|
weightMetric: weight(units:METRIC)
|
|
weightImperial: weight(units:IMPERIAL)
|
|
hairColor
|
|
hairLength
|
|
eyes
|
|
hasTattoos
|
|
hasPiercings
|
|
tattoos
|
|
piercings
|
|
description
|
|
createdAt
|
|
updatedAt
|
|
entity {
|
|
id
|
|
name
|
|
slug
|
|
type
|
|
parent {
|
|
id
|
|
name
|
|
slug
|
|
type
|
|
}
|
|
}
|
|
avatar: avatarMedia {
|
|
id
|
|
path
|
|
thumbnail
|
|
lazy
|
|
hash
|
|
comment
|
|
credit
|
|
sfw: sfwMedia {
|
|
id
|
|
thumbnail
|
|
path
|
|
comment
|
|
}
|
|
}
|
|
profiles: actorsProfiles(orderBy: PRIORITY_DESC) {
|
|
description
|
|
descriptionHash
|
|
entity {
|
|
id
|
|
name
|
|
slug
|
|
type
|
|
independent
|
|
parent {
|
|
id
|
|
name
|
|
slug
|
|
type
|
|
}
|
|
}
|
|
avatar: avatarMedia {
|
|
id
|
|
path
|
|
thumbnail
|
|
lazy
|
|
hash
|
|
comment
|
|
credit
|
|
sfw: sfwMedia {
|
|
id
|
|
thumbnail
|
|
path
|
|
comment
|
|
}
|
|
}
|
|
}
|
|
birthCity
|
|
birthState
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
residenceCity
|
|
residenceState
|
|
residenceCountry: countryByResidenceCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
social: actorsSocials {
|
|
id
|
|
url
|
|
platform
|
|
}
|
|
aliases: actorsByAliasFor {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
tags(selectableTags: $selectableTags) {
|
|
id
|
|
name
|
|
slug
|
|
priority
|
|
}
|
|
channels {
|
|
id
|
|
name
|
|
slug
|
|
type
|
|
independent
|
|
parent {
|
|
id
|
|
name
|
|
slug
|
|
type
|
|
}
|
|
}
|
|
scenesConnection(
|
|
filter: {
|
|
date: {
|
|
lessThan: $before,
|
|
greaterThan: $after,
|
|
}
|
|
or: $includedEntities
|
|
}
|
|
selectedTags: $includedTags
|
|
mode: $mode
|
|
first: $limit
|
|
offset: $offset
|
|
orderBy: $orderBy
|
|
) {
|
|
releases: nodes {
|
|
${releaseFields}
|
|
}
|
|
totalCount
|
|
}
|
|
}
|
|
}
|
|
`, {
|
|
actorId,
|
|
limit,
|
|
offset: Math.max(0, (pageNumber - 1)) * limit,
|
|
after,
|
|
before,
|
|
selectableTags: config.selectableTags,
|
|
orderBy,
|
|
excludeTags: store.state.ui.filter,
|
|
includedTags,
|
|
includedEntities: getIncludedEntities(router),
|
|
mode,
|
|
});
|
|
|
|
if (!actor) {
|
|
router.replace('/not-found');
|
|
return null;
|
|
}
|
|
|
|
return {
|
|
actor: curateActor(actor, null, curateRelease),
|
|
releases: actor.scenesConnection.releases.map(release => curateRelease(release)),
|
|
totalCount: actor.scenesConnection.totalCount,
|
|
};
|
|
}
|
|
|
|
async function fetchActors({ _commit }, {
|
|
limit = 10,
|
|
pageNumber = 1,
|
|
letter,
|
|
gender,
|
|
}) {
|
|
const genderFilter = (gender === null && 'gender: { isNull: true }')
|
|
|| (gender === 'all' && ' ')
|
|
|| `gender: { equalTo: "${gender}" }`;
|
|
|
|
const { connection: { actors, totalCount } } = await graphql(`
|
|
query Actors(
|
|
$limit: Int,
|
|
$offset: Int = 0,
|
|
$letter: String! = "",
|
|
) {
|
|
connection: actorsConnection(
|
|
first: $limit,
|
|
offset: $offset
|
|
orderBy: NAME_ASC
|
|
filter: {
|
|
aliasFor: {
|
|
isNull: true
|
|
}
|
|
name: {
|
|
startsWith: $letter
|
|
}
|
|
${genderFilter}
|
|
}
|
|
) {
|
|
totalCount
|
|
actors: nodes {
|
|
id
|
|
name
|
|
slug
|
|
age
|
|
ageAtDeath
|
|
dateOfBirth
|
|
dateOfDeath
|
|
gender
|
|
entity {
|
|
id
|
|
name
|
|
slug
|
|
type
|
|
parent {
|
|
id
|
|
name
|
|
slug
|
|
type
|
|
}
|
|
}
|
|
avatar: avatarMedia {
|
|
id
|
|
path
|
|
thumbnail
|
|
lazy
|
|
comment
|
|
credit
|
|
sfw: sfwMedia {
|
|
id
|
|
thumbnail
|
|
path
|
|
comment
|
|
}
|
|
}
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`, {
|
|
offset: Math.max(0, (pageNumber - 1)) * limit,
|
|
limit,
|
|
letter,
|
|
});
|
|
|
|
return {
|
|
actors: actors.map(actor => curateActor(actor)),
|
|
totalCount,
|
|
};
|
|
}
|
|
|
|
async function fetchActorReleases({ _commit }, actorId) {
|
|
const releases = await get(`/actors/${actorId}/releases`, {
|
|
filter: store.state.ui.filter,
|
|
after: store.getters.after,
|
|
before: store.getters.before,
|
|
});
|
|
|
|
return releases;
|
|
}
|
|
|
|
return {
|
|
fetchActorById,
|
|
fetchActors,
|
|
fetchActorReleases,
|
|
};
|
|
}
|
|
|
|
export default initActorActions;
|