Added JJ fix tool (hopefully no longer needed, but just in case).

This commit is contained in:
DebaucheryLibrarian 2024-08-27 02:27:47 +02:00
parent c5809bc289
commit 3aa542ab98
1 changed files with 47 additions and 0 deletions

View File

@ -0,0 +1,47 @@
'use strict';
// const config = require('config');
const initKnex = require('knex');
const unprint = require('unprint');
// const args = require('yargs').argv;
// const stashes = require('./julesjordan_stashes.json');
const slugify = require('../utils/slugify');
async function init() {
const knex = initKnex({
client: 'pg',
connection: {
host: 'syskill.unknown.name',
user: 'traxxx',
password: 'YGDdBeXZXE25gKuzh5g7u4RV61G00XP6',
database: 'traxxx',
},
asyncStackTraces: true,
});
const results = await knex('releases')
.select('releases.*')
.leftJoin('entities', 'entities.id', 'releases.entity_id')
.whereIn('entities.slug', ['julesjordan']);
await knex.transaction(async (trx) => {
return results.reduce(async (chain, scene) => {
await chain;
const newEntryId = slugify([scene.title, scene.date && unprint.formatDate(scene.date, 'YYYY-MM-DD')]);
console.log(newEntryId);
await trx('releases')
.where('id', scene.id)
.update({
entry_id: newEntryId,
comment: `old entry: ${scene.entryId}`,
});
}, Promise.resolve());
});
knex.destroy();
}
init();