forked from DebaucheryLibrarian/traxxx
41 lines
1003 B
JavaScript
41 lines
1003 B
JavaScript
|
'use strict';
|
||
|
|
||
|
const knex = require('./knex');
|
||
|
|
||
|
async function curateActor(actor) {
|
||
|
const aliases = await knex('actors')
|
||
|
.where({ alias_for: actor.id });
|
||
|
|
||
|
return {
|
||
|
id: actor.id,
|
||
|
name: actor.name,
|
||
|
description: actor.description,
|
||
|
birthdate: actor.birthdate && new Date(actor.birthdate),
|
||
|
country: actor.country_alpha2,
|
||
|
city: actor.city,
|
||
|
ethnicity: actor.ethnicity,
|
||
|
height: actor.height,
|
||
|
boobSize: actor.boobs_size,
|
||
|
boobsNatural: actor.boobs_natural,
|
||
|
aliases: aliases.map(({ name }) => name),
|
||
|
slug: actor.slug,
|
||
|
};
|
||
|
}
|
||
|
|
||
|
function curateActors(releases) {
|
||
|
return Promise.all(releases.map(async release => curateActor(release)));
|
||
|
}
|
||
|
|
||
|
async function fetchActors(actorId, actorSlug) {
|
||
|
const releases = await knex('actors')
|
||
|
.where({ id: actorId })
|
||
|
.orWhere({ slug: actorSlug })
|
||
|
.limit(100);
|
||
|
|
||
|
return curateActors(releases);
|
||
|
}
|
||
|
|
||
|
module.exports = {
|
||
|
fetchActors,
|
||
|
};
|