Switched to tabs. Adding missing actor entries when scraping actors, with batch ID.
This commit is contained in:
@@ -1,59 +1,61 @@
|
||||
import { graphql, get } from '../api';
|
||||
import {
|
||||
releasePosterFragment,
|
||||
releaseActorsFragment,
|
||||
releaseTagsFragment,
|
||||
releasePosterFragment,
|
||||
releaseActorsFragment,
|
||||
releaseTagsFragment,
|
||||
} from '../fragments';
|
||||
import { curateRelease } from '../curate';
|
||||
import getDateRange from '../get-date-range';
|
||||
|
||||
function curateActor(actor) {
|
||||
if (!actor) {
|
||||
return null;
|
||||
}
|
||||
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,
|
||||
},
|
||||
};
|
||||
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.avatar) {
|
||||
curatedActor.avatar = actor.avatar.media;
|
||||
}
|
||||
if (actor.avatar) {
|
||||
curatedActor.avatar = actor.avatar.media;
|
||||
}
|
||||
|
||||
if (actor.releases) {
|
||||
curatedActor.releases = actor.releases.map(release => curateRelease(release.release));
|
||||
}
|
||||
if (actor.releases) {
|
||||
curatedActor.releases = actor.releases.map(release => curateRelease(release.release));
|
||||
}
|
||||
|
||||
if (actor.photos) {
|
||||
curatedActor.photos = actor.photos.map(photo => photo.media);
|
||||
}
|
||||
if (actor.photos) {
|
||||
curatedActor.photos = actor.photos.map(photo => photo.media);
|
||||
}
|
||||
|
||||
return curatedActor;
|
||||
return curatedActor;
|
||||
}
|
||||
|
||||
function initActorActions(store, _router) {
|
||||
async function fetchActorBySlug({ _commit }, { actorSlug, limit = 100, range = 'latest' }) {
|
||||
const { before, after, orderBy } = getDateRange(range);
|
||||
async function fetchActorBySlug({ _commit }, { actorSlug, limit = 100, range = 'latest' }) {
|
||||
const { before, after, orderBy } = getDateRange(range);
|
||||
|
||||
const { actors: [actor] } = await graphql(`
|
||||
const { actors: [actor] } = await graphql(`
|
||||
query Actor(
|
||||
$actorSlug: String!
|
||||
$limit:Int = 1000,
|
||||
@@ -90,6 +92,8 @@ function initActorActions(store, _router) {
|
||||
tattoos
|
||||
piercings
|
||||
description
|
||||
createdAt
|
||||
updatedAt
|
||||
network {
|
||||
id
|
||||
name
|
||||
@@ -184,27 +188,27 @@ function initActorActions(store, _router) {
|
||||
}
|
||||
}
|
||||
`, {
|
||||
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,
|
||||
});
|
||||
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);
|
||||
}
|
||||
return curateActor(actor);
|
||||
}
|
||||
|
||||
async function fetchActors({ _commit }, {
|
||||
limit = 100,
|
||||
letter,
|
||||
gender,
|
||||
}) {
|
||||
const genderFilter = gender === null
|
||||
? 'isNull: true'
|
||||
: `equalTo: "${gender}"`;
|
||||
async function fetchActors({ _commit }, {
|
||||
limit = 100,
|
||||
letter,
|
||||
gender,
|
||||
}) {
|
||||
const genderFilter = gender === null
|
||||
? 'isNull: true'
|
||||
: `equalTo: "${gender}"`;
|
||||
|
||||
const { actors } = await graphql(`
|
||||
const { actors } = await graphql(`
|
||||
query Actors(
|
||||
$limit: Int,
|
||||
$letter: String! = "",
|
||||
@@ -249,28 +253,28 @@ function initActorActions(store, _router) {
|
||||
}
|
||||
}
|
||||
`, {
|
||||
limit,
|
||||
letter,
|
||||
});
|
||||
limit,
|
||||
letter,
|
||||
});
|
||||
|
||||
return actors.map(actor => curateActor(actor));
|
||||
}
|
||||
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,
|
||||
});
|
||||
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 releases;
|
||||
}
|
||||
|
||||
return {
|
||||
fetchActorBySlug,
|
||||
fetchActors,
|
||||
fetchActorReleases,
|
||||
};
|
||||
return {
|
||||
fetchActorBySlug,
|
||||
fetchActors,
|
||||
fetchActorReleases,
|
||||
};
|
||||
}
|
||||
|
||||
export default initActorActions;
|
||||
|
||||
@@ -3,11 +3,11 @@ import mutations from './mutations';
|
||||
import actions from './actions';
|
||||
|
||||
function initActorsStore(store, router) {
|
||||
return {
|
||||
state,
|
||||
mutations,
|
||||
actions: actions(store, router),
|
||||
};
|
||||
return {
|
||||
state,
|
||||
mutations,
|
||||
actions: actions(store, router),
|
||||
};
|
||||
}
|
||||
|
||||
export default initActorsStore;
|
||||
|
||||
Reference in New Issue
Block a user