Added date range to flush commands.

This commit is contained in:
DebaucheryLibrarian
2024-06-06 00:20:54 +02:00
parent 00653a7cab
commit a0ed434360
3 changed files with 73 additions and 7 deletions

View File

@@ -348,7 +348,18 @@ async function deleteSeries(serieIds) {
}
async function flushScenes() {
const sceneIds = await knex('releases').select('id').pluck('id');
const sceneIds = await knex('releases')
.select('id')
.modify((builder) => {
if (argv.flushAfter) {
builder.where('effective_date', '>=', argv.flushAfter);
}
if (argv.flushBefore) {
builder.where('effective_date', '<=', argv.flushBefore);
}
})
.pluck('id');
const confirmed = await inquirer.prompt([{
type: 'confirm',
@@ -421,10 +432,28 @@ async function flushBatches(batchIds) {
knex('releases')
.select('releases.id')
.whereIn('created_batch_id', batchIds)
.modify((builder) => {
if (argv.flushAfter) {
builder.where('effective_date', '>=', argv.flushAfter);
}
if (argv.flushBefore) {
builder.where('effective_date', '<=', argv.flushBefore);
}
})
.pluck('releases.id'),
knex('movies').whereIn('created_batch_id', batchIds)
.select('movies.id')
.whereIn('created_batch_id', batchIds)
.modify((builder) => {
if (argv.flushAfter) {
builder.where('effective_date', '>=', argv.flushAfter);
}
if (argv.flushBefore) {
builder.where('effective_date', '<=', argv.flushBefore);
}
})
.pluck('movies.id'),
]);