Added release type distinction to REST API.
This commit is contained in:
118
src/actors.js
118
src/actors.js
@@ -130,7 +130,7 @@ function toBaseActors(actorsOrNames, release) {
|
||||
});
|
||||
}
|
||||
|
||||
function curateActor(actor) {
|
||||
function curateActor(actor, withDetails = false) {
|
||||
if (!actor) {
|
||||
return null;
|
||||
}
|
||||
@@ -140,58 +140,64 @@ function curateActor(actor) {
|
||||
name: actor.name,
|
||||
slug: actor.slug,
|
||||
gender: actor.gender,
|
||||
alias: actor.alias && {
|
||||
id: actor.alias.id,
|
||||
name: actor.alias.name,
|
||||
gender: actor.alias.gender,
|
||||
},
|
||||
network: actor.network && {
|
||||
id: actor.network.id,
|
||||
name: actor.network.name,
|
||||
slug: actor.network.slug,
|
||||
},
|
||||
networkId: actor.network_id,
|
||||
aliasFor: actor.alias_for,
|
||||
dateOfBirth: actor.date_of_birth,
|
||||
dateOfDeath: actor.date_of_death,
|
||||
cup: actor.cup,
|
||||
bust: actor.bust,
|
||||
waist: actor.waist,
|
||||
hip: actor.hip,
|
||||
naturalBoobs: actor.natural_boobs,
|
||||
height: actor.height,
|
||||
weight: actor.weight,
|
||||
eyes: actor.eyes,
|
||||
hair: actor.hair,
|
||||
hasTattoos: actor.has_tattoos,
|
||||
hasPiercings: actor.has_piercings,
|
||||
tattoos: actor.tattoos,
|
||||
piercings: actor.piercings,
|
||||
description: actor.description,
|
||||
origin: actor.birth_country && {
|
||||
country: {
|
||||
alpha2: actor.birth_country.alpha2,
|
||||
name: actor.birth_country.name,
|
||||
alias: actor.birth_country.alias,
|
||||
birthCountry: actor.birth_country_alpha2,
|
||||
...(withDetails && {
|
||||
alias: actor.alias && {
|
||||
id: actor.alias.id,
|
||||
name: actor.alias.name,
|
||||
slug: actor.slug,
|
||||
gender: actor.alias.gender,
|
||||
},
|
||||
state: actor.birth_state,
|
||||
city: actor.birth_city,
|
||||
},
|
||||
residence: actor.residence_country && {
|
||||
country: {
|
||||
alpha2: actor.residence_country.alpha2,
|
||||
name: actor.residence_country.name,
|
||||
alias: actor.residence_country.alias,
|
||||
network: actor.network && {
|
||||
id: actor.network.id,
|
||||
name: actor.network.name,
|
||||
slug: actor.network.slug,
|
||||
},
|
||||
state: actor.residence_state,
|
||||
city: actor.residence_city,
|
||||
},
|
||||
avatar: actor.avatar && {
|
||||
id: actor.avatar.id,
|
||||
path: actor.avatar.path,
|
||||
width: actor.avatar.width,
|
||||
height: actor.avatar.height,
|
||||
size: actor.avatar.size,
|
||||
source: actor.avatar.source,
|
||||
},
|
||||
dateOfDeath: actor.date_of_death,
|
||||
cup: actor.cup,
|
||||
bust: actor.bust,
|
||||
waist: actor.waist,
|
||||
hip: actor.hip,
|
||||
naturalBoobs: actor.natural_boobs,
|
||||
height: actor.height,
|
||||
weight: actor.weight,
|
||||
eyes: actor.eyes,
|
||||
hair: actor.hair,
|
||||
hasTattoos: actor.has_tattoos,
|
||||
hasPiercings: actor.has_piercings,
|
||||
tattoos: actor.tattoos,
|
||||
piercings: actor.piercings,
|
||||
description: actor.description,
|
||||
placeOfBirth: actor.birth_country && {
|
||||
country: {
|
||||
alpha2: actor.birth_country.alpha2,
|
||||
name: actor.birth_country.name,
|
||||
alias: actor.birth_country.alias,
|
||||
},
|
||||
state: actor.birth_state,
|
||||
city: actor.birth_city,
|
||||
},
|
||||
placeOfResidence: actor.residence_country && {
|
||||
country: {
|
||||
alpha2: actor.residence_country.alpha2,
|
||||
name: actor.residence_country.name,
|
||||
alias: actor.residence_country.alias,
|
||||
},
|
||||
state: actor.residence_state,
|
||||
city: actor.residence_city,
|
||||
},
|
||||
avatar: actor.avatar && {
|
||||
id: actor.avatar.id,
|
||||
path: actor.avatar.path,
|
||||
width: actor.avatar.width,
|
||||
height: actor.avatar.height,
|
||||
size: actor.avatar.size,
|
||||
source: actor.avatar.source,
|
||||
},
|
||||
}),
|
||||
};
|
||||
|
||||
return curatedActor;
|
||||
@@ -724,11 +730,21 @@ async function fetchActor(actorId) {
|
||||
.leftJoin('media', 'media.id', 'actors.avatar_media_id')
|
||||
.first();
|
||||
|
||||
return curateActor(actor);
|
||||
return curateActor(actor, true);
|
||||
}
|
||||
|
||||
async function searchActors(query) {
|
||||
const actors = await knex
|
||||
.select('*')
|
||||
.from(knex.raw('search_actors(?) as actors', [query]))
|
||||
.limit(10);
|
||||
|
||||
return actors.map(actor => curateActor(actor));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
associateActors,
|
||||
fetchActor,
|
||||
scrapeActors,
|
||||
searchActors,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user