Generating thumbnails. Added site overview page.
This commit is contained in:
@@ -35,6 +35,24 @@ async function fetchActors(actorId, actorSlug) {
|
||||
return curateActors(releases);
|
||||
}
|
||||
|
||||
async function storeActors(release, releaseEntry) {
|
||||
const actors = await knex('actors').whereIn('name', release.actors);
|
||||
const newActors = release.actors.filter(actorName => !actors.some(actor => actor.name === actorName));
|
||||
|
||||
const { rows: insertedActors } = newActors.length
|
||||
? await knex.raw(`${knex('actors').insert(newActors.map(actorName => ({
|
||||
name: actorName,
|
||||
slug: actorName.toLowerCase().replace(/\s+/g, '-'),
|
||||
})))} ON CONFLICT DO NOTHING RETURNING *`)
|
||||
: { rows: [] };
|
||||
|
||||
return knex('actors_associated').insert(actors.concat(insertedActors).map(actor => ({
|
||||
release_id: releaseEntry.id,
|
||||
actor_id: actor.id,
|
||||
})), '*');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
fetchActors,
|
||||
storeActors,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user