Fixed SQL total and pagination, showing end of result info. Hiding heart from scene tiles when not logged in.

This commit is contained in:
2024-03-17 22:15:11 +01:00
parent 3f36c0ae0a
commit 3238e678ef
6 changed files with 114 additions and 74 deletions

View File

@@ -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,