Added actor names to Jules Jordan title entry ID.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
// const config = require('config');
|
||||
const initKnex = require('knex');
|
||||
const unprint = require('unprint');
|
||||
// const unprint = require('unprint');
|
||||
// const args = require('yargs').argv;
|
||||
// const stashes = require('./julesjordan_stashes.json');
|
||||
const slugify = require('../utils/slugify');
|
||||
@@ -20,15 +20,19 @@ async function init() {
|
||||
});
|
||||
|
||||
const results = await knex('releases')
|
||||
.select('releases.*')
|
||||
.select('releases.*', knex.raw('json_agg(actors.name) as actor_names'))
|
||||
.leftJoin('entities', 'entities.id', 'releases.entity_id')
|
||||
.whereIn('entities.slug', ['julesjordan']);
|
||||
.leftJoin('releases_actors', 'releases_actors.release_id', 'releases.id')
|
||||
.leftJoin('actors', 'actors.id', 'releases_actors.actor_id')
|
||||
.whereIn('entities.slug', ['julesjordan'])
|
||||
.groupBy('releases.id');
|
||||
|
||||
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')]);
|
||||
// const newEntryId = scene.entry_id.replace(/-\d{4}-\d{2}-\d{2}$/, ''); // remove date
|
||||
const newEntryId = slugify([scene.title, ...(scene.actor_names?.toSorted() || [])]);
|
||||
|
||||
console.log(newEntryId);
|
||||
|
||||
@@ -36,7 +40,7 @@ async function init() {
|
||||
.where('id', scene.id)
|
||||
.update({
|
||||
entry_id: newEntryId,
|
||||
comment: `old entry: ${scene.entryId}`,
|
||||
comment: `old entry id: ${scene.entry_id}`,
|
||||
});
|
||||
}, Promise.resolve());
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user