Added batch ID and better feedback to StashDB import tool.
This commit is contained in:
parent
40bb73e897
commit
36ba4542a6
|
|
@ -42,6 +42,11 @@ exports.up = async (knex) => {
|
|||
table.integer('source_submissions');
|
||||
table.json('source_meta');
|
||||
|
||||
table.integer('batch_id')
|
||||
.notNullable()
|
||||
.references('id')
|
||||
.inTable('batches');
|
||||
|
||||
table.datetime('source_created_at');
|
||||
|
||||
table.datetime('created_at')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
'use strict';
|
||||
|
||||
const util = require('util');
|
||||
// const util = require('util');
|
||||
const unprint = require('unprint');
|
||||
const args = require('yargs').argv;
|
||||
|
||||
|
|
@ -79,7 +79,10 @@ async function curateData(data) {
|
|||
return release;
|
||||
});
|
||||
|
||||
console.log(`Found ${stashScenes.length} scenes in StashDB`);
|
||||
|
||||
const stashScenesByIdentifiers = Object.fromEntries(stashScenes.flatMap((scene) => [[scene.entryId || scene.urlId, scene], [scene.url, scene]]));
|
||||
const [{ id: batchId }] = await knex('batches').insert({ showcased: false, comment: 'StashDB fingerprints' }).returning('id');
|
||||
|
||||
const sceneEntries = await knex('releases')
|
||||
.select('releases.*')
|
||||
|
|
@ -88,6 +91,8 @@ async function curateData(data) {
|
|||
.where('entities.slug', 'hardx')
|
||||
.whereIn('entry_id', stashScenes.map((scene) => scene.entryId || scene.urlId));
|
||||
|
||||
console.log(`Matched ${sceneEntries.length} scenes`);
|
||||
|
||||
const fpEntries = sceneEntries.flatMap((scene) => {
|
||||
const stashScene = stashScenesByIdentifiers[scene.entry_id]
|
||||
|| stashScenesByIdentifiers[scene.url];
|
||||
|
|
@ -108,15 +113,16 @@ async function curateData(data) {
|
|||
url: stashScene.url,
|
||||
date: stashScene.date,
|
||||
},
|
||||
batch_id: batchId,
|
||||
}));
|
||||
});
|
||||
|
||||
console.log(util.inspect(fpEntries, { colors: true, depth: null, maxArrayLength: null }));
|
||||
// console.log(util.inspect(fpEntries, { colors: true, depth: null, maxArrayLength: null }));
|
||||
|
||||
if (args.update) {
|
||||
await bulkInsert('releases_fingerprints', fpEntries, false);
|
||||
|
||||
console.log(`Inserted ${fpEntries.length} hash entries`);
|
||||
console.log(`Inserted ${fpEntries.length} hash entries in batch ${batchId}`);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue