From 3238e678ef3377dc66ab6e8f8ba1ba5a052394f9 Mon Sep 17 00:00:00 2001 From: DebaucheryLibrarian Date: Sun, 17 Mar 2024 22:15:11 +0100 Subject: [PATCH] Fixed SQL total and pagination, showing end of result info. Hiding heart from scene tiles when not logged in. --- components/pagination/pagination.vue | 168 ++++++++++++++++----------- components/scenes/scenes.vue | 2 - components/scenes/tile.vue | 2 +- src/actors.js | 5 + src/scenes.js | 10 +- src/web/server.js | 1 + 6 files changed, 114 insertions(+), 74 deletions(-) diff --git a/components/pagination/pagination.vue b/components/pagination/pagination.vue index 132c10a..72cf3d1 100644 --- a/components/pagination/pagination.vue +++ b/components/pagination/pagination.vue @@ -1,81 +1,88 @@ diff --git a/components/scenes/scenes.vue b/components/scenes/scenes.vue index ad6f8a3..d62f96e 100644 --- a/components/scenes/scenes.vue +++ b/components/scenes/scenes.vue @@ -169,8 +169,6 @@ const scope = ref(routeParams.scope || props.defaultScope); const total = ref(Number(pageProps.total)); const loading = ref(false); -console.log('SCOPE', routeParams.scope, scope.value); - const actorIds = urlParsed.search.actors?.split(',').map((identifier) => parseActorIdentifier(identifier)?.id).filter(Boolean) || []; const queryActors = actorIds.map((urlActorId) => aggActors.value.find((aggActor) => aggActor.id === urlActorId)).filter(Boolean); diff --git a/components/scenes/tile.vue b/components/scenes/tile.vue index 0d53b2b..656e99e 100644 --- a/components/scenes/tile.vue +++ b/components/scenes/tile.vue @@ -28,7 +28,7 @@ /> Number(hit._id)); diff --git a/src/scenes.js b/src/scenes.js index 4534c6e..b80e8ab 100644 --- a/src/scenes.js +++ b/src/scenes.js @@ -377,7 +377,8 @@ async function queryManticoreSql(filters, options, _reqUser) { max_query_time=:maxQueryTime: :actorsFacet: :tagsFacet: - :channelsFacet: + :channelsFacet:; + show meta; `, { query: knexManticore(filters.stashId ? 'scenes_stashed' : 'scenes') .modify((builder) => { @@ -459,6 +460,7 @@ async function queryManticoreSql(filters, options, _reqUser) { } }) .limit(options.limit) + .offset((options.page - 1) * options.limit) .toString(), // option threads=1 fixes actors, but drastically slows down performance, wait for fix actorsFacet: options.aggregateActors ? knex.raw('facet scenes.actor_ids order by count(*) desc limit ?', [aggSize]) : null, @@ -496,9 +498,11 @@ async function queryManticoreSql(filters, options, _reqUser) { ?.data.map((row) => ({ key: row.channel_id || row['scenes.channel_id'], doc_count: row['count(*)'] })) || []; + const total = results.at(-1).data.find((entry) => entry.Variable_name === 'total_found').Value; + return { scenes: results[0].data, - total: results[0].total, + total, aggregations: { actorIds, tagIds, @@ -546,6 +550,8 @@ export async function fetchScenes(filters, rawOptions, reqUser) { const scenes = await fetchScenesById(sceneIds, reqUser); console.timeEnd('fetch full'); + console.log('total', result.total); + return { scenes, aggActors, diff --git a/src/web/server.js b/src/web/server.js index 6d6452b..5571a75 100644 --- a/src/web/server.js +++ b/src/web/server.js @@ -148,6 +148,7 @@ export default async function initServer() { env: { allowLogin: config.auth.login, allowSignup: config.auth.signup, + maxMatches: config.database.manticore.maxMatches, maxAggregateSize: config.database.manticore.maxAggregateSize, }, };