From 3aa542ab987a46197d595b0c5f3c30a93eaa0e45 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Tue, 27 Aug 2024 02:27:47 +0200 Subject: [PATCH] Added JJ fix tool (hopefully no longer needed, but just in case). --- src/tools/julesjordan-fix.js | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/tools/julesjordan-fix.js diff --git a/src/tools/julesjordan-fix.js b/src/tools/julesjordan-fix.js new file mode 100644 index 00000000..071826b7 --- /dev/null +++ b/src/tools/julesjordan-fix.js @@ -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();