Using alias actor ID when available. Using basic SVG flags instead of PNG. Moved PNG and HD SVG flags to assets.

This commit is contained in:
2020-05-13 20:27:06 +02:00
parent 6040a3f41f
commit dac451bb86
1198 changed files with 90809 additions and 16620 deletions

View File

@@ -42,7 +42,7 @@ function curateActorEntries(baseActors, batchId) {
async function getOrCreateActors(baseActors, batchId) {
const existingActors = await knex('actors')
.select('id', 'name', 'slug', 'network_id')
.select('id', 'alias_for', 'name', 'slug', 'network_id')
.whereIn('slug', baseActors.map(baseActor => baseActor.slug))
.whereNull('network_id')
.orWhereIn(['slug', 'network_id'], baseActors.map(baseActor => [baseActor.slug, baseActor.network.id]));
@@ -59,7 +59,7 @@ async function getOrCreateActors(baseActors, batchId) {
const uniqueBaseActors = baseActors.filter(baseActor => !existingActorSlugs[baseActor.network.id]?.[baseActor.slug] && !existingActorSlugs.null?.[baseActor.slug]);
const curatedActorEntries = curateActorEntries(uniqueBaseActors, batchId);
const newActors = await knex('actors').insert(curatedActorEntries, ['id', 'name', 'slug', 'network_id']);
const newActors = await knex('actors').insert(curatedActorEntries, ['id', 'alias_for', 'name', 'slug', 'network_id']);
if (Array.isArray(newActors)) {
return newActors.concat(existingActors);
@@ -83,7 +83,6 @@ async function associateActors(releases, batchId) {
return;
}
// const baseActorsBySlug = baseActors.reduce((acc, baseActor) => ({ ...acc, [baseActor.slug]: baseActor }), {});
const baseActorsBySlugAndNetworkId = baseActors.reduce((acc, baseActor) => ({
...acc,
[baseActor.slug]: {
@@ -95,15 +94,17 @@ async function associateActors(releases, batchId) {
const uniqueBaseActors = Object.values(baseActorsBySlugAndNetworkId).map(baseActorsByNetworkId => Object.values(baseActorsByNetworkId)).flat();
const actors = await getOrCreateActors(uniqueBaseActors, batchId);
// const actorIdsBySlug = actors.reduce((acc, actor) => ({ ...acc, [actor.slug]: actor.id }), {});
console.log(actors);
const actorIdsBySlugAndNetworkId = actors.reduce((acc, actor) => ({
...acc,
[actor.network_id]: {
...acc[actor.network_id],
[actor.slug]: actor.id,
[actor.slug]: actor.alias_for || actor.id,
},
}), {});
console.log(actorIdsBySlugAndNetworkId);
const releaseActorAssociations = Object.entries(baseActorsByReleaseId)
.map(([releaseId, releaseActors]) => releaseActors
.map(releaseActor => ({