From 3645c2a0e68dc0041928cfb620eebf22db1b63c2 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Fri, 13 Nov 2026 22:56:51 +0100 Subject: [PATCH] Showing non-showcased batches in latest and upcoming, only meant to be excluded from new. --- pages/updates/+onBeforeRender.js | 5 ++++- src/scenes.js | 4 ++++ src/sync.js | 4 +++- src/web/scenes.js | 1 + tools/manticore-actors.js | 4 ++-- tools/manticore-movies.js | 4 ++-- tools/manticore-scenes.js | 5 +++-- tools/manticore-stashes.js | 4 ++-- tools/run-tool.js | 16 ++++++++++++++++ 9 files changed, 37 insertions(+), 10 deletions(-) diff --git a/pages/updates/+onBeforeRender.js b/pages/updates/+onBeforeRender.js index 51b8018..2317369 100644 --- a/pages/updates/+onBeforeRender.js +++ b/pages/updates/+onBeforeRender.js @@ -4,6 +4,7 @@ import { curateScenesQuery } from '#/src/web/scenes.js'; export async function onBeforeRender(pageContext) { const withQuery = Object.hasOwn(pageContext.urlParsed.search, 'q'); + const scope = pageContext.routeParams.scope || 'latest'; const [ sceneResults, @@ -11,8 +12,10 @@ export async function onBeforeRender(pageContext) { ] = await Promise.all([ fetchScenes(await curateScenesQuery({ ...pageContext.urlQuery, - scope: pageContext.routeParams.scope || 'latest', + scope, isShowcased: withQuery ? null : true, + // New sorts by scrape date, so large scrape batches would drown it out, they still show up in Latest and Upcoming + isBatchShowcased: !withQuery && scope === 'new' ? true : null, tagFilter: pageContext.tagFilter, }), { page: Number(pageContext.routeParams.page) || 1, diff --git a/src/scenes.js b/src/scenes.js index 277c18c..6abfd76 100644 --- a/src/scenes.js +++ b/src/scenes.js @@ -639,6 +639,10 @@ async function queryManticoreSql(filters, options, _reqUser) { builder.where('scenes.is_showcased', filters.isShowcased); } + if (typeof filters.isBatchShowcased === 'boolean') { + builder.where('scenes.is_batch_showcased', filters.isBatchShowcased); + } + if (options.dedupe) { builder.where('scenes.dupe_index', '<', 2); } diff --git a/src/sync.js b/src/sync.js index 6ae35ba..e2ef99f 100644 --- a/src/sync.js +++ b/src/sync.js @@ -128,8 +128,9 @@ export async function syncManticoreScenes(sceneIds) { studios.showcased IS NOT false AND (entities.showcased IS NOT false OR COALESCE(studios.showcased, false) = true) AND (parents.showcased IS NOT false OR COALESCE(entities.showcased, false) = true OR COALESCE(studios.showcased, false) = true) - AND (releases_summaries.batch_showcased IS NOT false) AS showcased, + -- kept separate from the channel showcasing, a batch only hides large scrapes from New, not from Latest and Upcoming + releases_summaries.batch_showcased IS NOT false AS batch_showcased, row_number() OVER (PARTITION BY releases.entry_id, parents.id ORDER BY releases.effective_date DESC) as dupe_index FROM releases LEFT JOIN releases_summaries ON releases_summaries.release_id = releases.id @@ -232,6 +233,7 @@ export async function syncManticoreScenes(sceneIds) { created_at: Math.round(scene.created_at.getTime() / 1000), effective_date: Math.round((scene.date || scene.created_at).getTime() / 1000), is_showcased: scene.showcased, + is_batch_showcased: scene.batch_showcased, shoot_id: scene.shoot_id || undefined, channel_id: scene.channel_id, channel_slug: scene.channel_slug, diff --git a/src/web/scenes.js b/src/web/scenes.js index 8a5b657..f098059 100644 --- a/src/web/scenes.js +++ b/src/web/scenes.js @@ -57,6 +57,7 @@ export async function curateScenesQuery(query) { serieId: Number(query.serieId) || null, stashId: Number(query.stashId) || null, isShowcased: typeof query.isShowcased === 'boolean' ? query.isShowcased : null, + isBatchShowcased: typeof query.isBatchShowcased === 'boolean' ? query.isBatchShowcased : null, }; } diff --git a/tools/manticore-actors.js b/tools/manticore-actors.js index ae93716..8fbc0dc 100644 --- a/tools/manticore-actors.js +++ b/tools/manticore-actors.js @@ -2,7 +2,7 @@ import argv from '../src/argv.js'; import { utilsApi } from '../src/manticore.js'; import { syncManticoreActors } from '../src/sync.js'; -import runTool from './run-tool.js'; +import runTool, { isMain } from './run-tool.js'; export async function rebuildActors() { await utilsApi.sql('drop table if exists actors'); @@ -33,7 +33,7 @@ export async function rebuildActors() { await syncManticoreActors(); } -if (import.meta.main) { +if (isMain(import.meta.url)) { runTool(async () => { if (argv.update) { await rebuildActors(); diff --git a/tools/manticore-movies.js b/tools/manticore-movies.js index db8f0d9..bc9562b 100644 --- a/tools/manticore-movies.js +++ b/tools/manticore-movies.js @@ -1,7 +1,7 @@ import argv from '../src/argv.js'; import { utilsApi } from '../src/manticore.js'; import { syncManticoreMovies } from '../src/sync.js'; -import runTool from './run-tool.js'; +import runTool, { isMain } from './run-tool.js'; export async function rebuildMovies() { await utilsApi.sql('drop table if exists movies'); @@ -37,7 +37,7 @@ export async function rebuildMovies() { await syncManticoreMovies(); } -if (import.meta.main) { +if (isMain(import.meta.url)) { runTool(async () => { if (argv.update) { await rebuildMovies(); diff --git a/tools/manticore-scenes.js b/tools/manticore-scenes.js index 36c7e72..0dce59d 100644 --- a/tools/manticore-scenes.js +++ b/tools/manticore-scenes.js @@ -1,7 +1,7 @@ import argv from '../src/argv.js'; import { utilsApi } from '../src/manticore.js'; import { syncManticoreScenes } from '../src/sync.js'; -import runTool from './run-tool.js'; +import runTool, { isMain } from './run-tool.js'; export async function rebuildScenes() { await utilsApi.sql('drop table if exists scenes'); @@ -40,6 +40,7 @@ export async function rebuildScenes() { date bigint, fingerprints text, is_showcased bool, + is_batch_showcased bool, created_at bigint, effective_date bigint, stashed int, @@ -62,7 +63,7 @@ export async function rebuildScenes() { await syncManticoreScenes(); } -if (import.meta.main) { +if (isMain(import.meta.url)) { runTool(async () => { if (argv.update) { await rebuildScenes(); diff --git a/tools/manticore-stashes.js b/tools/manticore-stashes.js index 5e1c557..c21a6a9 100644 --- a/tools/manticore-stashes.js +++ b/tools/manticore-stashes.js @@ -1,6 +1,6 @@ import { utilsApi } from '../src/manticore.js'; import { syncStashes } from '../src/sync.js'; -import runTool from './run-tool.js'; +import runTool, { isMain } from './run-tool.js'; export async function rebuildStashes() { await utilsApi.sql('drop table if exists scenes_stashed'); @@ -37,6 +37,6 @@ export async function rebuildStashes() { await syncStashes('movie'); } -if (import.meta.main) { +if (isMain(import.meta.url)) { runTool(rebuildStashes); } diff --git a/tools/run-tool.js b/tools/run-tool.js index cf8d29e..a34429e 100644 --- a/tools/run-tool.js +++ b/tools/run-tool.js @@ -1,8 +1,24 @@ +import { realpathSync } from 'node:fs'; import process from 'node:process'; +import { fileURLToPath } from 'node:url'; import { knexOwner as knex } from '../src/knex.js'; import redis from '../src/redis.js'; +// whether the module was run directly rather than imported, a stand-in for import.meta.main, which needs node 24.2 or 22.18 +export function isMain(moduleUrl) { + if (!process.argv[1]) { + return false; + } + + try { + return realpathSync(process.argv[1]) === realpathSync(fileURLToPath(moduleUrl)); + } + catch (_error) { + return false; + } +} + // runs a command line tool and closes the connections afterwards, the knex pool and redis would otherwise keep the process alive export default async function runTool(tool) { try {