forked from DebaucheryLibrarian/traxxx
Storing scene language and production date precision. Refactored Teen Core Club.
This commit is contained in:
@@ -70,6 +70,7 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
|
||||
if (type === 'scene') {
|
||||
curatedRelease.shoot_id = release.shootId || null;
|
||||
curatedRelease.production_date = Number(release.productionDate) ? release.productionDate : null;
|
||||
curatedRelease.production_date_precision = release.productionDatePrecision;
|
||||
curatedRelease.duration = Math.round(release.duration) || null; // float may happen if scraper converts duration from milliseconds with a simple / 1000
|
||||
curatedRelease.qualities = Array.from(new Set(release.qualities?.map(Number).filter(Boolean))).sort((qualityA, qualityB) => qualityB - qualityA);
|
||||
}
|
||||
@@ -89,6 +90,20 @@ async function curateReleaseEntry(release, batchId, existingRelease, type = 'sce
|
||||
}
|
||||
}
|
||||
|
||||
if (release.language) {
|
||||
const curatedLanguage = release.language.toLowerCase();
|
||||
|
||||
const language = await knex('languages')
|
||||
.where(knex.raw('lower(alpha2)'), curatedLanguage)
|
||||
.orWhere(knex.raw('lower(name)'), curatedLanguage)
|
||||
.orWhere(knex.raw('lower(name_native)'), curatedLanguage)
|
||||
.first();
|
||||
|
||||
if (language) {
|
||||
curatedRelease.language_alpha2 = language.alpha2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!existingRelease && !release.id) {
|
||||
curatedRelease.created_batch_id = batchId;
|
||||
}
|
||||
@@ -443,12 +458,15 @@ async function storeScenes(releases, useBatchId) {
|
||||
description = COALESCE(new.description, releases.description),
|
||||
shoot_id = COALESCE(new.shoot_id, releases.shoot_id),
|
||||
duration = COALESCE(new.duration, releases.duration),
|
||||
production_date = COALESCE(new.production_date, releases.production_date),
|
||||
production_date_precision = COALESCE(new.production_date_precision, releases.production_date_precision),
|
||||
language_alpha2 = COALESCE(new.language_alpha2, releases.language_alpha2),
|
||||
comment = COALESCE(new.comment, releases.comment),
|
||||
attributes = COALESCE(new.attributes::jsonb || releases.attributes::jsonb, new.attributes::jsonb, releases.attributes::jsonb),
|
||||
deep = new.url IS NOT NULL,
|
||||
updated_at = NOW()
|
||||
FROM json_to_recordset(:scenes)
|
||||
AS new(id int, url text, date timestamptz, entity json, title text, description text, shoot_id text, duration integer, comment text, attributes json, deep boolean)
|
||||
AS new(id int, url text, date timestamptz, entity json, title text, description text, shoot_id text, duration integer, production_date timestamptz, production_date_precision text, language_alpha2 text, comment text, attributes json, deep boolean)
|
||||
WHERE releases.id = new.id
|
||||
RETURNING releases.*
|
||||
`, {
|
||||
|
||||
Reference in New Issue
Block a user