Only curating release ID when present.

This commit is contained in:
DebaucheryLibrarian
2023-06-16 02:29:01 +02:00
parent 682f299c8f
commit 7723b2b698
2 changed files with 8 additions and 6 deletions

View File

@@ -30,7 +30,6 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
});
const curatedRelease = {
id: release.id, // release is updated
title: decode(release.title),
entry_id: release.entryId || null,
entity_id: release.entity.id,
@@ -46,6 +45,11 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
updated_batch_id: batchId,
};
if (release.id) {
// release is updated
curatedRelease.id = release.id;
}
if (type === 'scene') {
curatedRelease.shoot_id = release.shootId || null;
curatedRelease.production_date = Number(release.productionDate) ? release.productionDate : null;
@@ -474,8 +478,6 @@ async function storeScenes(releases, useBatchId) {
const curatedDuplicateReleases = await Promise.all(duplicateReleasesWithId.map((release) => curateReleaseEntry(release, batchId)));
const releasesWithId = uniqueReleasesWithId.concat(duplicateReleasesWithId);
console.log(curatedDuplicateReleases);
const updated = await knex.raw(`
UPDATE releases
SET url = COALESCE(new.url, releases.url),