diff --git a/migrations/20230725031547_stealth_batch.js b/migrations/20230725031547_stealth_batch.js new file mode 100644 index 00000000..3aba478d --- /dev/null +++ b/migrations/20230725031547_stealth_batch.js @@ -0,0 +1,13 @@ +exports.up = async (knex) => { + await knex.schema.alterTable('batches', (table) => { + table.boolean('showcased') + .notNullable() + .defaultTo(true); + }); +}; + +exports.down = async (knex) => { + await knex.schema.alterTable('batches', (table) => { + table.dropColumn('showcased'); + }); +}; diff --git a/src/argv.js b/src/argv.js index d4df5df2..66e39b2a 100755 --- a/src/argv.js +++ b/src/argv.js @@ -366,6 +366,12 @@ const { argv } = yargs alias: ['timeout'], default: 60000, }) + .option('showcased', { + describe: 'Whether the batch should be showcased as new.', + type: 'boolean', + alias: ['showcase', 'batch-showcased'], + default: true, + }) .coerce('after', interpretAfter) .coerce('actors-update', (after) => interpretAfter(after, true)); diff --git a/src/store-releases.js b/src/store-releases.js index 8697eb85..b3a5c6e2 100755 --- a/src/store-releases.js +++ b/src/store-releases.js @@ -343,7 +343,7 @@ async function storeMovies(movies, useBatchId) { } const { uniqueReleases } = await filterDuplicateReleases(movies); - const [batchId] = useBatchId ? [useBatchId] : await knex('batches').insert({ comment: null }).returning('id'); + const [batchId] = useBatchId ? [useBatchId] : await knex('batches').insert({ showcased: argv.showcased, comment: null }).returning('id'); const curatedMovieEntries = await Promise.all(uniqueReleases.map((release) => curateReleaseEntry(release, batchId, null, 'movie'))); @@ -362,7 +362,7 @@ async function storeSeries(series, useBatchId) { } const { uniqueReleases } = await filterDuplicateReleases(series); - const [batchId] = useBatchId ? [useBatchId] : await knex('batches').insert({ comment: null }).returning('id'); + const [batchId] = useBatchId ? [useBatchId] : await knex('batches').insert({ showcased: argv.showcased, comment: null }).returning('id'); const curatedSerieEntries = await Promise.all(uniqueReleases.map((release) => curateReleaseEntry(release, batchId, null, 'serie'))); @@ -380,7 +380,7 @@ async function storeScenes(releases, useBatchId) { return []; } - const [batchId] = useBatchId ? [useBatchId] : await knex('batches').insert({ comment: null }).returning('id'); + const [batchId] = useBatchId ? [useBatchId] : await knex('batches').insert({ showcased: argv.showcased, comment: null }).returning('id'); const releasesWithChannels = await attachChannelEntities(releases); const releasesWithBaseActors = releasesWithChannels.map((release) => ({ ...release, actors: toBaseActors(release.actors) }));