2019-12-15 22:01:48 +00:00
|
|
|
import { graphql, get } from '../api';
|
2019-12-31 02:12:52 +00:00
|
|
|
import {
|
|
|
|
releasePosterFragment,
|
|
|
|
releaseActorsFragment,
|
|
|
|
releaseTagsFragment,
|
|
|
|
} from '../fragments';
|
|
|
|
import { curateRelease } from '../curate';
|
2019-12-15 22:01:48 +00:00
|
|
|
|
|
|
|
function curateActor(actor) {
|
|
|
|
const curatedActor = {
|
|
|
|
...actor,
|
2019-12-16 01:39:13 +00:00
|
|
|
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,
|
2019-12-15 22:01:48 +00:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2020-01-02 16:13:57 +00:00
|
|
|
if (actor.avatar) {
|
|
|
|
curatedActor.avatar = actor.avatar.media;
|
|
|
|
}
|
|
|
|
|
2019-12-31 02:12:52 +00:00
|
|
|
if (actor.releases) {
|
|
|
|
curatedActor.releases = actor.releases.map(release => curateRelease(release.release));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (actor.photos) {
|
|
|
|
curatedActor.photos = actor.photos.map(photo => photo.media);
|
|
|
|
}
|
|
|
|
|
2019-12-15 22:01:48 +00:00
|
|
|
return curatedActor;
|
|
|
|
}
|
2019-11-10 03:20:22 +00:00
|
|
|
|
2019-11-15 04:10:59 +00:00
|
|
|
function initActorActions(store, _router) {
|
2020-01-04 01:51:58 +00:00
|
|
|
async function fetchActorBySlug(actorSlug, limit = 100) {
|
2019-12-15 22:01:48 +00:00
|
|
|
const { actor } = await graphql(`
|
2020-01-04 01:51:58 +00:00
|
|
|
query Actor(
|
|
|
|
$actorSlug: String!
|
|
|
|
$limit:Int = 1000,
|
|
|
|
$after:Date = "1900-01-01",
|
|
|
|
$before:Date = "2100-01-01",
|
2020-01-08 23:23:37 +00:00
|
|
|
$orderBy:[ReleasesActorsOrderBy!]
|
2020-01-30 22:41:10 +00:00
|
|
|
$exclude: [String!]
|
2020-01-04 01:51:58 +00:00
|
|
|
) {
|
|
|
|
actor: actorBySlug(slug: $actorSlug) {
|
2019-12-15 22:01:48 +00:00
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
2019-12-16 01:39:13 +00:00
|
|
|
gender
|
|
|
|
birthdate
|
|
|
|
age
|
|
|
|
ethnicity
|
|
|
|
bust
|
|
|
|
waist
|
|
|
|
hip
|
2020-01-23 21:45:46 +00:00
|
|
|
naturalBoobs
|
2019-12-16 01:39:13 +00:00
|
|
|
heightMetric: height(units:METRIC)
|
|
|
|
heightImperial: height(units:IMPERIAL)
|
|
|
|
weightMetric: weight(units:METRIC)
|
|
|
|
weightImperial: weight(units:IMPERIAL)
|
|
|
|
hasTattoos
|
|
|
|
hasPiercings
|
|
|
|
tattoos
|
|
|
|
piercings
|
2020-01-22 21:25:58 +00:00
|
|
|
description
|
2019-12-31 02:12:52 +00:00
|
|
|
avatar: actorsAvatarByActorId {
|
|
|
|
media {
|
|
|
|
thumbnail
|
|
|
|
path
|
2020-02-24 02:12:58 +00:00
|
|
|
copyright
|
2019-12-31 02:12:52 +00:00
|
|
|
}
|
2019-12-15 22:01:48 +00:00
|
|
|
}
|
2019-12-31 02:12:52 +00:00
|
|
|
photos: actorsPhotos {
|
|
|
|
media {
|
|
|
|
id
|
|
|
|
thumbnail
|
|
|
|
path
|
|
|
|
index
|
2020-02-24 02:12:58 +00:00
|
|
|
copyright
|
2019-12-31 02:12:52 +00:00
|
|
|
}
|
2019-12-16 01:39:13 +00:00
|
|
|
}
|
|
|
|
birthCity
|
|
|
|
birthState
|
|
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
2019-12-15 22:01:48 +00:00
|
|
|
alpha2
|
|
|
|
name
|
|
|
|
alias
|
|
|
|
}
|
2019-12-16 01:39:13 +00:00
|
|
|
residenceCity
|
|
|
|
residenceState
|
|
|
|
residenceCountry: countryByResidenceCountryAlpha2 {
|
|
|
|
alpha2
|
|
|
|
name
|
|
|
|
alias
|
|
|
|
}
|
2019-12-31 02:12:52 +00:00
|
|
|
social: actorsSocials {
|
2019-12-16 01:39:13 +00:00
|
|
|
id
|
|
|
|
url
|
|
|
|
platform
|
|
|
|
}
|
2019-12-15 22:01:48 +00:00
|
|
|
aliases: actorsByAliasFor {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
}
|
2020-01-04 01:51:58 +00:00
|
|
|
releases: releasesActors(
|
|
|
|
filter: {
|
|
|
|
release: {
|
|
|
|
date: {
|
|
|
|
lessThan: $before,
|
|
|
|
greaterThan: $after,
|
2020-01-30 22:41:10 +00:00
|
|
|
},
|
|
|
|
releasesTags: {
|
|
|
|
none: {
|
|
|
|
tag: {
|
|
|
|
slug: {
|
|
|
|
in: $exclude
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-01-04 01:51:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
first: $limit,
|
2020-01-08 23:23:37 +00:00
|
|
|
orderBy: $orderBy
|
2020-01-04 01:51:58 +00:00
|
|
|
) {
|
2019-12-31 02:12:52 +00:00
|
|
|
release {
|
|
|
|
id
|
|
|
|
url
|
|
|
|
title
|
|
|
|
date
|
2020-02-22 22:25:10 +00:00
|
|
|
slug
|
2019-12-31 02:12:52 +00:00
|
|
|
${releaseActorsFragment}
|
|
|
|
${releaseTagsFragment}
|
|
|
|
${releasePosterFragment}
|
|
|
|
site {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
url
|
|
|
|
network {
|
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
|
|
|
url
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-12-15 22:01:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
actorSlug,
|
2020-01-04 01:51:58 +00:00
|
|
|
limit,
|
|
|
|
after: store.getters.after,
|
|
|
|
before: store.getters.before,
|
2020-01-08 23:23:37 +00:00
|
|
|
orderBy: store.state.ui.range === 'upcoming' ? 'RELEASE_BY_RELEASE_ID__DATE_ASC' : 'RELEASE_BY_RELEASE_ID__DATE_DESC',
|
2020-01-30 22:41:10 +00:00
|
|
|
exclude: store.state.ui.filter,
|
2019-12-15 22:01:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return curateActor(actor);
|
|
|
|
}
|
|
|
|
|
2020-02-09 04:30:10 +00:00
|
|
|
async function fetchActors({ _commit }, {
|
|
|
|
actorSlug,
|
|
|
|
limit = 100,
|
|
|
|
letter,
|
|
|
|
genders,
|
|
|
|
}) {
|
2019-12-15 22:01:48 +00:00
|
|
|
if (actorSlug) {
|
|
|
|
return fetchActorBySlug(actorSlug);
|
2019-12-01 04:32:47 +00:00
|
|
|
}
|
2020-02-23 04:23:07 +00:00
|
|
|
console.log(genders);
|
2019-11-10 03:20:22 +00:00
|
|
|
|
2019-12-15 22:01:48 +00:00
|
|
|
const { actors } = await graphql(`
|
2020-02-09 04:30:10 +00:00
|
|
|
query Actors(
|
|
|
|
$limit: Int,
|
|
|
|
$letter: String! = "",
|
|
|
|
$genders: [String!] = ["female"],
|
|
|
|
) {
|
|
|
|
actors(
|
|
|
|
first:$limit,
|
|
|
|
orderBy: NAME_ASC,
|
|
|
|
filter: {
|
|
|
|
name: {
|
|
|
|
startsWith: $letter
|
|
|
|
},
|
2020-02-14 01:30:43 +00:00
|
|
|
or: [
|
|
|
|
{
|
|
|
|
gender: {
|
|
|
|
in: $genders
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
gender: {
|
|
|
|
isNull: true
|
|
|
|
},
|
|
|
|
}
|
|
|
|
]
|
2020-02-09 04:30:10 +00:00
|
|
|
},
|
|
|
|
) {
|
2019-12-15 22:01:48 +00:00
|
|
|
id
|
|
|
|
name
|
|
|
|
slug
|
2020-01-02 16:13:57 +00:00
|
|
|
age
|
|
|
|
birthdate
|
2020-01-25 00:26:13 +00:00
|
|
|
gender
|
2019-12-31 02:12:52 +00:00
|
|
|
avatar: actorsAvatarByActorId {
|
|
|
|
media {
|
|
|
|
thumbnail
|
|
|
|
}
|
2019-12-15 22:01:48 +00:00
|
|
|
}
|
2019-12-16 01:39:13 +00:00
|
|
|
birthCountry: countryByBirthCountryAlpha2 {
|
2019-12-15 22:01:48 +00:00
|
|
|
alpha2
|
|
|
|
name
|
|
|
|
alias
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
`, {
|
|
|
|
limit,
|
2020-02-09 04:30:10 +00:00
|
|
|
letter,
|
2020-02-23 04:23:07 +00:00
|
|
|
genders: genders.filter(Boolean),
|
|
|
|
genderNull: genders.some(gender => gender === null),
|
2019-12-15 22:01:48 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
return actors.map(actor => curateActor(actor));
|
2019-11-10 03:20:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async function fetchActorReleases({ _commit }, actorId) {
|
2019-11-15 04:10:59 +00:00
|
|
|
const releases = await get(`/actors/${actorId}/releases`, {
|
|
|
|
filter: store.state.ui.filter,
|
|
|
|
after: store.getters.after,
|
|
|
|
before: store.getters.before,
|
|
|
|
});
|
2019-11-10 03:20:22 +00:00
|
|
|
|
|
|
|
return releases;
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
fetchActors,
|
|
|
|
fetchActorReleases,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
export default initActorActions;
|