diff --git a/pages/movies/+onBeforeRender.js b/pages/movies/+onBeforeRender.js index c12c62b..45b8aca 100644 --- a/pages/movies/+onBeforeRender.js +++ b/pages/movies/+onBeforeRender.js @@ -8,6 +8,7 @@ export async function onBeforeRender(pageContext) { }), { page: Number(pageContext.routeParams.page) || 1, limit: Number(pageContext.urlParsed.search.limit) || 50, + dedupe: true, }, pageContext.user); return { diff --git a/pages/updates/+onBeforeRender.js b/pages/updates/+onBeforeRender.js index 8dd59c3..7a15a6b 100644 --- a/pages/updates/+onBeforeRender.js +++ b/pages/updates/+onBeforeRender.js @@ -18,6 +18,7 @@ export async function onBeforeRender(pageContext) { page: Number(pageContext.routeParams.page) || 1, limit: Number(pageContext.urlParsed.search.limit) || 29, aggregate: withQuery, + dedupe: true, }, pageContext.user), getRandomCampaigns([ { minRatio: 1.5 }, diff --git a/src/movies.js b/src/movies.js index 84bc6f7..ac780d4 100644 --- a/src/movies.js +++ b/src/movies.js @@ -204,11 +204,12 @@ function curateOptions(options) { return { limit: options?.limit || 30, page: Number(options?.page) || 1, - aggregate: options.aggregate ?? true, - aggregateYears: (options.aggregate ?? true) && (options.aggregateYears ?? true), - aggregateActors: (options.aggregate ?? true) && (options.aggregateActors ?? true), - aggregateTags: (options.aggregate ?? true) && (options.aggregateTags ?? true), - aggregateChannels: (options.aggregate ?? true) && (options.aggregateChannels ?? true), + aggregate: options?.aggregate ?? true, + aggregateYears: (options?.aggregate ?? true) && (options?.aggregateYears ?? true), + aggregateActors: (options?.aggregate ?? true) && (options?.aggregateActors ?? true), + aggregateTags: (options?.aggregate ?? true) && (options?.aggregateTags ?? true), + aggregateChannels: (options?.aggregate ?? true) && (options?.aggregateChannels ?? true), + dedupe: !!options?.dedupe, }; } @@ -290,6 +291,10 @@ async function queryManticoreSql(filters, options) { builder.where('is_showcased', filters.isShowcased); } + if (options.dedupe) { + builder.where('movies.dupe_index', '<', 2); + } + if (!filters.scope || filters.scope === 'latest') { builder .where('effective_date', '<=', Math.round(Date.now() / 1000)) diff --git a/src/scenes.js b/src/scenes.js index 60dbfca..b829f7d 100644 --- a/src/scenes.js +++ b/src/scenes.js @@ -358,13 +358,14 @@ function curateOptions(options) { return { limit: options?.limit || 30, page: Number(options?.page) || 1, - aggregate: options.aggregate ?? true, - aggregateYears: (options.aggregate ?? true) && (options.aggregateYears ?? true), - aggregateActors: (options.aggregate ?? true) && (options.aggregateActors ?? true), - aggregateTags: (options.aggregate ?? true) && (options.aggregateTags ?? true), - aggregateChannels: (options.aggregate ?? true) && (options.aggregateChannels ?? true), - index: options.index || 'scenes', - useSql: options.useSql || (typeof options.useSql === 'undefined' && sqlImplied.includes(options.index)) || false, + aggregate: options?.aggregate ?? true, + aggregateYears: (options?.aggregate ?? true) && (options?.aggregateYears ?? true), + aggregateActors: (options?.aggregate ?? true) && (options?.aggregateActors ?? true), + aggregateTags: (options?.aggregate ?? true) && (options?.aggregateTags ?? true), + aggregateChannels: (options?.aggregate ?? true) && (options?.aggregateChannels ?? true), + dedupe: !!options?.dedupe, + index: options?.index || 'scenes', + useSql: options?.useSql || (typeof options?.useSql === 'undefined' && sqlImplied.includes(options?.index)) || false, }; } @@ -480,6 +481,10 @@ async function queryManticoreSql(filters, options, _reqUser) { builder.where('scenes.date', '>', 0); } + if (options.dedupe) { + builder.where('scenes.dupe_index', '<', 2); + } + if (!filters.scope || filters.scope === 'latest') { builder .where('effective_date', '<=', Math.round(Date.now() / 1000))