forked from DebaucheryLibrarian/traxxx
Added JJ fix tool (hopefully no longer needed, but just in case).
This commit is contained in:
parent
c5809bc289
commit
3aa542ab98
|
@ -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();
|
Loading…
Reference in New Issue