forked from DebaucheryLibrarian/traxxx
Added scene flush. Added temporary media insert log for integer out of range error.
This commit is contained in:
parent
91746c73e1
commit
ba3b87471e
|
@ -11,7 +11,7 @@ const { fetchScenes, fetchMovies } = require('./deep');
|
|||
const { storeScenes, storeMovies, updateReleasesSearch } = require('./store-releases');
|
||||
const { scrapeActors, flushActors, flushProfiles, interpolateProfiles } = require('./actors');
|
||||
const { flushEntities } = require('./entities');
|
||||
const { deleteScenes, deleteMovies, flushBatches } = require('./releases');
|
||||
const { deleteScenes, deleteMovies, flushScenes, flushBatches } = require('./releases');
|
||||
const { flushOrphanedMedia } = require('./media');
|
||||
const getFileEntries = require('./utils/file-entries');
|
||||
|
||||
|
@ -45,6 +45,10 @@ async function init() {
|
|||
await flushBatches(argv.flushBatches);
|
||||
}
|
||||
|
||||
if (argv.flushScenes) {
|
||||
await flushScenes();
|
||||
}
|
||||
|
||||
if (argv.deleteScenes) {
|
||||
await deleteScenes(argv.deleteScenes);
|
||||
}
|
||||
|
|
|
@ -283,6 +283,10 @@ const { argv } = yargs
|
|||
type: 'array',
|
||||
alias: 'flush-batch',
|
||||
})
|
||||
.option('flush-scenes', {
|
||||
describe: 'Remove all scenes.',
|
||||
type: 'boolean',
|
||||
})
|
||||
.option('delete-scenes', {
|
||||
describe: 'Remove scenes by ID.',
|
||||
type: 'array',
|
||||
|
|
|
@ -657,7 +657,9 @@ async function storeMedias(baseMedias, options) {
|
|||
const newMediaWithEntries = savedMedias.filter(Boolean).map((media, index) => curateMediaEntry(media, index));
|
||||
const newMediaEntries = newMediaWithEntries.filter(media => media.newEntry).map(media => media.entry);
|
||||
|
||||
await bulkInsert('media', newMediaEntries);
|
||||
console.log('insert error', newMediaEntries.filter(mediaEntry => Object.values(mediaEntry).some(value => Number(value) && Number(value) > 1000000)));
|
||||
|
||||
await bulkInsert('media', newMediaEntries, false);
|
||||
|
||||
return [...newMediaWithEntries, ...existingHashMedias];
|
||||
}
|
||||
|
|
|
@ -155,6 +155,27 @@ async function deleteScenes(sceneIds) {
|
|||
return deleteCount;
|
||||
}
|
||||
|
||||
async function flushScenes() {
|
||||
const sceneIds = await knex('releases').select('id').pluck('id');
|
||||
|
||||
const confirmed = await inquirer.prompt([{
|
||||
type: 'confirm',
|
||||
name: 'flushScenes',
|
||||
message: `You are about to remove ${sceneIds.length} scenes. Are you sure?`,
|
||||
default: false,
|
||||
}]);
|
||||
|
||||
if (!confirmed.flushScenes) {
|
||||
logger.warn('Confirmation rejected, not flushing scenes');
|
||||
return;
|
||||
}
|
||||
const deleteCount = await deleteScenes(sceneIds);
|
||||
|
||||
await flushOrphanedMedia();
|
||||
|
||||
logger.info(`Removed ${deleteCount}/${sceneIds.length} scenes`);
|
||||
}
|
||||
|
||||
async function deleteMovies(movieIds) {
|
||||
if (movieIds.length === 0) {
|
||||
return 0;
|
||||
|
@ -208,6 +229,7 @@ module.exports = {
|
|||
fetchScene,
|
||||
fetchScenes,
|
||||
flushBatches,
|
||||
flushScenes,
|
||||
searchScenes,
|
||||
deleteScenes,
|
||||
deleteMovies,
|
||||
|
|
Loading…
Reference in New Issue