forked from DebaucheryLibrarian/traxxx
272 lines
7.7 KiB
JavaScript
272 lines
7.7 KiB
JavaScript
import { graphql, get } from '../api';
|
|
import {
|
|
releasePosterFragment,
|
|
releaseActorsFragment,
|
|
releaseTagsFragment,
|
|
} from '../fragments';
|
|
import { curateRelease } from '../curate';
|
|
import getDateRange from '../get-date-range';
|
|
|
|
function curateActor(actor) {
|
|
if (!actor) {
|
|
return null;
|
|
}
|
|
|
|
const curatedActor = {
|
|
...actor,
|
|
height: actor.heightMetric && {
|
|
metric: actor.heightMetric,
|
|
imperial: actor.heightImperial,
|
|
},
|
|
weight: actor.weightMetric && {
|
|
metric: actor.weightMetric,
|
|
imperial: actor.weightImperial,
|
|
},
|
|
origin: actor.birthCountry && {
|
|
city: actor.birthCity,
|
|
state: actor.birthState,
|
|
country: actor.birthCountry,
|
|
},
|
|
residence: actor.residenceCountry && {
|
|
city: actor.residenceCity,
|
|
state: actor.residenceState,
|
|
country: actor.residenceCountry,
|
|
},
|
|
scrapedAt: new Date(actor.createdAt),
|
|
updatedAt: new Date(actor.updatedAt),
|
|
};
|
|
|
|
if (actor.profiles && actor.profiles.length > 0) {
|
|
curatedActor.avatar = actor.profiles.slice(0, 1)[0].avatar;
|
|
curatedActor.photos = actor.profiles.slice(1).map(profile => profile.avatar);
|
|
}
|
|
|
|
if (actor.releases) {
|
|
curatedActor.releases = actor.releases.map(release => curateRelease(release.release));
|
|
}
|
|
|
|
return curatedActor;
|
|
}
|
|
|
|
function initActorActions(store, _router) {
|
|
async function fetchActorBySlug({ _commit }, { actorSlug, limit = 100, range = 'latest' }) {
|
|
const { before, after, orderBy } = getDateRange(range);
|
|
|
|
const { actors: [actor] } = await graphql(`
|
|
query Actor(
|
|
$actorSlug: String!
|
|
$limit:Int = 1000,
|
|
$after:Date = "1900-01-01",
|
|
$before:Date = "2100-01-01",
|
|
$orderBy:[ReleasesActorsOrderBy!]
|
|
$exclude: [String!]
|
|
) {
|
|
actors(filter: {
|
|
slug: {
|
|
equalTo: $actorSlug,
|
|
},
|
|
networkId: {
|
|
isNull: true,
|
|
},
|
|
}) {
|
|
id
|
|
name
|
|
slug
|
|
gender
|
|
birthdate: dateOfBirth
|
|
age
|
|
ethnicity
|
|
bust
|
|
waist
|
|
hip
|
|
naturalBoobs
|
|
heightMetric: height(units:METRIC)
|
|
heightImperial: height(units:IMPERIAL)
|
|
weightMetric: weight(units:METRIC)
|
|
weightImperial: weight(units:IMPERIAL)
|
|
hasTattoos
|
|
hasPiercings
|
|
tattoos
|
|
piercings
|
|
description
|
|
createdAt
|
|
updatedAt
|
|
network {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
profiles: actorsProfiles {
|
|
description
|
|
avatar: avatarMedia {
|
|
id
|
|
path
|
|
thumbnail
|
|
lazy
|
|
comment
|
|
copyright
|
|
}
|
|
}
|
|
birthCity
|
|
birthState
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
residenceCity
|
|
residenceState
|
|
residenceCountry: countryByResidenceCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
social: actorsSocials {
|
|
id
|
|
url
|
|
platform
|
|
}
|
|
aliases: actorsByAliasFor {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
releases: releasesActors(
|
|
filter: {
|
|
release: {
|
|
date: {
|
|
lessThan: $before,
|
|
greaterThan: $after,
|
|
},
|
|
releasesTags: {
|
|
none: {
|
|
tag: {
|
|
slug: {
|
|
in: $exclude
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
first: $limit,
|
|
orderBy: $orderBy
|
|
) {
|
|
release {
|
|
id
|
|
url
|
|
title
|
|
date
|
|
slug
|
|
${releaseActorsFragment}
|
|
${releaseTagsFragment}
|
|
${releasePosterFragment}
|
|
site {
|
|
id
|
|
name
|
|
slug
|
|
url
|
|
network {
|
|
id
|
|
name
|
|
slug
|
|
url
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`, {
|
|
actorSlug,
|
|
limit,
|
|
after,
|
|
before,
|
|
orderBy: orderBy === 'DATE_DESC' ? 'RELEASE_BY_RELEASE_ID__DATE_DESC' : 'RELEASE_BY_RELEASE_ID__DATE_ASC',
|
|
exclude: store.state.ui.filter,
|
|
});
|
|
|
|
return curateActor(actor);
|
|
}
|
|
|
|
async function fetchActors({ _commit }, {
|
|
limit = 100,
|
|
letter,
|
|
gender,
|
|
}) {
|
|
const genderFilter = gender === null
|
|
? 'isNull: true'
|
|
: `equalTo: "${gender}"`;
|
|
|
|
const { actors } = await graphql(`
|
|
query Actors(
|
|
$limit: Int,
|
|
$letter: String! = "",
|
|
) {
|
|
actors(
|
|
first:$limit,
|
|
orderBy: NAME_ASC,
|
|
filter: {
|
|
name: {
|
|
startsWith: $letter
|
|
},
|
|
gender: {
|
|
${genderFilter}
|
|
},
|
|
},
|
|
) {
|
|
id
|
|
name
|
|
slug
|
|
age
|
|
birthdate: dateOfBirth
|
|
gender
|
|
network {
|
|
id
|
|
name
|
|
slug
|
|
}
|
|
actorsProfiles {
|
|
actorsAvatarByProfileId {
|
|
media {
|
|
id
|
|
path
|
|
thumbnail
|
|
copyright
|
|
}
|
|
}
|
|
}
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
|
alpha2
|
|
name
|
|
alias
|
|
}
|
|
}
|
|
}
|
|
`, {
|
|
limit,
|
|
letter,
|
|
});
|
|
|
|
return actors.map(actor => curateActor(actor));
|
|
}
|
|
|
|
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 {
|
|
fetchActorBySlug,
|
|
fetchActors,
|
|
fetchActorReleases,
|
|
};
|
|
}
|
|
|
|
export default initActorActions;
|