Fixed actor birthdate and social links scraping.
This commit is contained in:
parent
d113123778
commit
884ef248e4
|
@ -141,6 +141,17 @@ async function fetchActors(queryObject) {
|
|||
return curateActors(releases);
|
||||
}
|
||||
|
||||
async function storeSocialLinks(actor) {
|
||||
const existingSocialLinks = await knex('social').where({
|
||||
domain: 'actors',
|
||||
target_id: actor.id,
|
||||
});
|
||||
|
||||
const newSocialLinks = actor.social.filter(url => !existingSocialLinks.some(existingLink => url === existingLink.url));
|
||||
|
||||
await knex('social').insert(curateSocialEntries(newSocialLinks, actor));
|
||||
}
|
||||
|
||||
async function storeActor(actor, scraped = false, scrapeSuccess = false) {
|
||||
const curatedActor = curateActorEntry(actor, scraped, scrapeSuccess);
|
||||
|
||||
|
@ -148,7 +159,7 @@ async function storeActor(actor, scraped = false, scrapeSuccess = false) {
|
|||
.insert(curatedActor)
|
||||
.returning('*');
|
||||
|
||||
await knex('social').insert(curateSocialEntries(actor.social, actor));
|
||||
await storeSocialLinks({ ...actor, ...actorEntry });
|
||||
|
||||
console.log(`Added new entry for actor '${actor.name}'`);
|
||||
|
||||
|
@ -163,7 +174,7 @@ async function updateActor(actor, scraped = false, scrapeSuccess = false) {
|
|||
.update(curatedActor)
|
||||
.returning('*');
|
||||
|
||||
await knex('social').insert(curateSocialEntries(actor.social, actor));
|
||||
await storeSocialLinks({ ...actor, ...curatedActor, ...actorEntry });
|
||||
|
||||
console.log(`Updated entry for actor '${actor.name}'`);
|
||||
|
||||
|
@ -181,7 +192,7 @@ function mergeProfiles(profiles, actor) {
|
|||
name: actor ? actor.name : profile.name,
|
||||
description: prevProfile.description || profile.description,
|
||||
gender: prevProfile.gender || profile.gender,
|
||||
birthdate: Number.isNaN(prevProfile.birthdate) ? profile.birthdate : prevProfile.birthdate,
|
||||
birthdate: Number.isNaN(Number(prevProfile.birthdate)) ? profile.birthdate : prevProfile.birthdate,
|
||||
birthCountry: prevProfile.birthCountry || profile.birthCountry,
|
||||
residenceCountry: prevProfile.residenceCountry || profile.residenceCountry,
|
||||
birthPlace: prevProfile.birthPlace || profile.birthPlace,
|
||||
|
|
Loading…
Reference in New Issue