Generating thumbnails. Added site overview page.

This commit is contained in:
2019-11-11 03:20:00 +01:00
parent 948597d265
commit 50816d7b28
28 changed files with 780 additions and 182 deletions

View File

@@ -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,
};