Refactoring client to reflect database changes.

This commit is contained in:
2019-12-19 04:42:50 +01:00
parent 31aee71edb
commit 1c43884102
9 changed files with 114 additions and 78 deletions

View File

@@ -399,7 +399,7 @@ async function scrapeBasicActors() {
async function associateActors(mappedActors, releases) {
const [existingActorEntries, existingAssociationEntries] = await Promise.all([
knex('actors').whereIn('name', Object.keys(mappedActors)),
knex('actors_associated').whereIn('release_id', releases.map(release => release.id)),
knex('releases_actors').whereIn('release_id', releases.map(release => release.id)),
]);
const associations = await Promise.map(Object.entries(mappedActors), async ([actorName, releaseIds]) => {
@@ -418,7 +418,7 @@ async function associateActors(mappedActors, releases) {
});
await Promise.all([
knex('actors_associated').insert(associations.flat()),
knex('releases_actors').insert(associations.flat()),
scrapeBasicActors(),
]);
}