Added Hitzefrei. Fixed date averaging.

This commit is contained in:
DebaucheryLibrarian
2020-07-21 04:04:07 +02:00
parent dff4d15872
commit d56da74168
39 changed files with 263 additions and 10 deletions

View File

@@ -97,11 +97,11 @@ function getMostFrequentDate(dates) {
const month = getMostFrequent(dates.map(dateX => dateX.getMonth()));
const date = getMostFrequent(dates.map(dateX => dateX.getDate()));
if (year && month && date) {
return moment({ year, month, date }).toDate();
if (year === null || month === null || date === null) {
return null;
}
return null;
return moment({ year, month, date }).toDate();
}
function getLongest(items) {
@@ -216,7 +216,7 @@ function curateActorEntry(baseActor, batchId) {
name: baseActor.name,
slug: baseActor.slug,
entity_id: null,
entry_id: baseActor.entry_id,
entry_id: baseActor.entryId,
batch_id: batchId,
};
}
@@ -615,6 +615,8 @@ async function scrapeActors(actorNames) {
const [batchId] = newBaseActors.length > 0 ? await knex('batches').insert({ comment: null }).returning('id') : [null];
const curatedActorEntries = batchId && curateActorEntries(newBaseActors, batchId);
// TODO: associate entity when entry ID is provided
const newActorEntries = batchId && await knex('actors')
.insert(curatedActorEntries)
.returning(['id', 'name', 'slug', 'entry_id']);