Added actor flush, renamed inconsistent actor flush to actor delete.
This commit is contained in:
parent
dbfbd1f04d
commit
80b8fe3654
|
@ -8,6 +8,7 @@ const blake2 = require('blake2');
|
|||
const DOMPurify = require('dompurify');
|
||||
const { JSDOM } = require('jsdom');
|
||||
const omit = require('object.omit');
|
||||
const inquirer = require('inquirer');
|
||||
|
||||
const { window } = new JSDOM('');
|
||||
const domPurify = DOMPurify(window);
|
||||
|
@ -973,7 +974,7 @@ async function flushProfiles(actorIdsOrNames) {
|
|||
logger.info(`Removed ${deleteCount} profiles`);
|
||||
}
|
||||
|
||||
async function flushActors(actorIdsOrNames) {
|
||||
async function deleteActors(actorIdsOrNames) {
|
||||
const actors = await knex('actors')
|
||||
.whereIn('id', actorIdsOrNames.filter(idOrName => typeof idOrName === 'number'))
|
||||
.orWhere((builder) => {
|
||||
|
@ -1002,8 +1003,31 @@ async function flushActors(actorIdsOrNames) {
|
|||
logger.info(`Removed ${deletedActorsCount} actors with ${deletedScenesCount} scenes`);
|
||||
}
|
||||
|
||||
async function flushActors() {
|
||||
const actorIds = await knex('actors').select('id').pluck('id');
|
||||
|
||||
const confirmed = await inquirer.prompt([{
|
||||
type: 'confirm',
|
||||
name: 'flushActors',
|
||||
message: `You are about to remove ${actorIds.length} actors. Are you sure?`,
|
||||
default: false,
|
||||
}]);
|
||||
|
||||
if (!confirmed.flushActors) {
|
||||
logger.warn('Confirmation rejected, not flushing actors');
|
||||
return;
|
||||
}
|
||||
|
||||
const deleteCount = await deleteActors(actorIds);
|
||||
|
||||
await flushOrphanedMedia();
|
||||
|
||||
logger.info(`Removed ${deleteCount}/${actorIds.length} actors`);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
associateActors,
|
||||
deleteActors,
|
||||
fetchActor,
|
||||
flushActors,
|
||||
flushProfiles,
|
||||
|
|
|
@ -9,7 +9,7 @@ const knex = require('./knex');
|
|||
const fetchUpdates = require('./updates');
|
||||
const { fetchScenes, fetchMovies } = require('./deep');
|
||||
const { storeScenes, storeMovies, updateReleasesSearch, associateMovieScenes } = require('./store-releases');
|
||||
const { scrapeActors, flushActors, flushProfiles, interpolateProfiles } = require('./actors');
|
||||
const { scrapeActors, deleteActors, flushActors, flushProfiles, interpolateProfiles } = require('./actors');
|
||||
const { flushEntities } = require('./entities');
|
||||
const { deleteScenes, deleteMovies, flushScenes, flushMovies, flushBatches } = require('./releases');
|
||||
const { flushOrphanedMedia } = require('./media');
|
||||
|
@ -53,6 +53,10 @@ async function init() {
|
|||
await flushMovies();
|
||||
}
|
||||
|
||||
if (argv.deleteActors) {
|
||||
await deleteActors(argv.deleteActors);
|
||||
}
|
||||
|
||||
if (argv.deleteScenes) {
|
||||
await deleteScenes(argv.deleteScenes);
|
||||
}
|
||||
|
|
|
@ -269,7 +269,7 @@ const { argv } = yargs
|
|||
alias: 'flush-network',
|
||||
})
|
||||
.option('flush-actors', {
|
||||
describe: 'Delete actors with profiles and scenes.',
|
||||
describe: 'Flush all actors and their scenes.',
|
||||
type: 'array',
|
||||
alias: 'flush-actor',
|
||||
})
|
||||
|
@ -291,6 +291,11 @@ const { argv } = yargs
|
|||
describe: 'Remove all movies.',
|
||||
type: 'boolean',
|
||||
})
|
||||
.option('delete-actors', {
|
||||
describe: 'Remove actors by ID.',
|
||||
type: 'array',
|
||||
alias: ['delete-actor', 'remove-actors', 'remove-actor'],
|
||||
})
|
||||
.option('delete-scenes', {
|
||||
describe: 'Remove scenes by ID.',
|
||||
type: 'array',
|
||||
|
|
Loading…
Reference in New Issue