Restored actor tag filtering with performance fixes.

This commit is contained in:
2026-03-22 04:50:35 +01:00
parent 884ad891f3
commit fea28b71ba
2 changed files with 37 additions and 39 deletions

View File

@@ -12,25 +12,25 @@
<Icon icon="search" /> <Icon icon="search" />
</label> </label>
<!-- <template v-if="isActorTagsAvailable">
<div <div
v-show="showActorTags" v-show="showActorTags"
v-tooltip="'Tags relevant to the selected actors'" v-tooltip="'Tags relevant to the selected actors'"
class="filter-sort order noselect" class="filter-sort order noselect"
@click="showActorTags = false" @click="showActorTags = false"
> >
<Icon icon="user-tags" /> <Icon icon="user-tags" />
</div> </div>
<div <div
v-show="!showActorTags" v-show="!showActorTags"
v-tooltip="'All tags'" v-tooltip="'All tags'"
class="filter-sort order noselect" class="filter-sort order noselect"
@click="showActorTags = true" @click="showActorTags = true"
> >
<Icon icon="price-tags" /> <Icon icon="price-tags" />
</div> </div>
--> </template>
<div <div
v-show="order === 'priority'" v-show="order === 'priority'"
@@ -142,13 +142,17 @@ const props = defineProps({
const emit = defineEmits(['update']); const emit = defineEmits(['update']);
const { pageProps } = inject('pageContext'); const { pageProps } = inject('pageContext');
// const { tag: pageTag, actor: pageActor } = pageProps;
const { tag: pageTag } = pageProps; const {
tag: pageTag,
actor: pageActor,
stash: pageStash,
} = pageProps;
const search = ref(''); const search = ref('');
const searchRegexp = computed(() => new RegExp(search.value, 'i')); const searchRegexp = computed(() => new RegExp(search.value, 'i'));
const order = ref('priority'); const order = ref('priority');
// const showActorTags = ref(true); const showActorTags = ref(!!pageActor);
const priorityTags = [ const priorityTags = [
'anal', 'anal',
@@ -173,13 +177,13 @@ const priorityTags = [
'lesbian', 'lesbian',
]; ];
const isActorTagsAvailable = computed(() => props.actorTags && (props.filters.actors.length > 0 || pageActor) && !pageStash);
const groupedTags = computed(() => { const groupedTags = computed(() => {
/* // can't show actor tags inside stash, because both require a join, and manticore currently only supports one
const tags = showActorTags.value && props.actorTags && (props.filters.actors.length > 0 || pageActor) const tags = showActorTags.value && isActorTagsAvailable.value
? props.actorTags ? props.actorTags
: props.tags; : props.tags;
*/
const tags = props.tags;
const selected = tags.filter((tag) => props.filters.tags.includes(tag.slug)); const selected = tags.filter((tag) => props.filters.tags.includes(tag.slug));
const filtered = tags.filter((tag) => !props.filters.tags.includes(tag.slug) const filtered = tags.filter((tag) => !props.filters.tags.includes(tag.slug)

View File

@@ -406,10 +406,10 @@ function curateOptions(options) {
} }
// function curateFacet(results, field, count = 'count(distinct id)') { // function curateFacet(results, field, count = 'count(distinct id)') {
function curateFacet(results, field, count = 'count(*)') { function curateFacet(results, field) {
return results return results
.find((result) => result.columns[0][field] && result.columns[1][count]) .find((result) => result.columns[0][field] && (result.columns[1]['count(distinct id)'] || result.columns[1]['count(*)']))
?.data.map((row) => ({ key: row[field], doc_count: row[count] })) ?.data.map((row) => ({ key: row[field], doc_count: row['count(distinct id)'] || row['count(*)'] }))
.filter((row) => !!row.key) .filter((row) => !!row.key)
|| []; || [];
} }
@@ -436,6 +436,7 @@ async function queryManticoreSql(filters, options, _reqUser) {
:yearsFacet: :yearsFacet:
:actorsFacet: :actorsFacet:
:tagsFacet: :tagsFacet:
:actorTagsFacet:
:channelsFacet: :channelsFacet:
:studiosFacet:; :studiosFacet:;
show meta; show meta;
@@ -469,12 +470,10 @@ async function queryManticoreSql(filters, options, _reqUser) {
weight() as _score weight() as _score
`)); `));
/* // manticore only supports one joined table, so we can't use it inside stashes
// manticore only supports one joined table, so we can't use it inside stashes; probably not needed anyway (stashes only need global tags?)
builder builder
.leftJoin('scenes_tags', 'scenes_tags.scene_id', 'scenes_.id') .leftJoin('scenes_tags', 'scenes_tags.scene_id', 'scenes_.id')
.groupBy('scenes.id'); .groupBy('scenes.id');
*/
} }
if (filters.query) { if (filters.query) {
@@ -581,12 +580,10 @@ async function queryManticoreSql(filters, options, _reqUser) {
yearsFacet: options.aggregateYears ? knex.raw('facet effective_year as years_facet order by effective_year desc limit ?', [aggSize]) : null, yearsFacet: options.aggregateYears ? knex.raw('facet effective_year as years_facet order by effective_year desc limit ?', [aggSize]) : null,
actorsFacet: options.aggregateActors ? knex.raw('facet scenes.actor_ids as actors_facet distinct id order by count(*) desc limit ?', [aggSize]) : null, actorsFacet: options.aggregateActors ? knex.raw('facet scenes.actor_ids as actors_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
// don't facet tags associated to other actors, actor ID 0 means global // don't facet tags associated to other actors, actor ID 0 means global
tagsFacet: options.aggregateTags ? knex.raw('facet scenes.tag_ids as tags_facet order by count(*) desc limit ?', [aggSize]) : null, tagsFacet: options.aggregateTags ? knex.raw('facet scenes.tag_ids as tags_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
/*
actorTagsFacet: options.aggregateTags && !filters.stashId // eslint-disable-line no-nested-ternary actorTagsFacet: options.aggregateTags && !filters.stashId // eslint-disable-line no-nested-ternary
? knex.raw(`facet IF(IN(scenes_tags.actor_id, ${[0, ...filters?.actorIds || []]}), scenes_tags.tag_id, 0) as actor_tags_facet distinct id order by count(*) desc limit ?`, [aggSize]) ? knex.raw(`facet IF(IN(scenes_tags.actor_id, ${[0, ...filters?.actorIds || []]}), scenes_tags.tag_id, 0) as actor_tags_facet distinct id order by count(*) desc limit ?`, [aggSize])
: null, : null,
*/
channelsFacet: options.aggregateChannels ? knex.raw('facet scenes.channel_id as channels_facet distinct id order by count(*) desc limit ?', [aggSize]) : null, channelsFacet: options.aggregateChannels ? knex.raw('facet scenes.channel_id as channels_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
studiosFacet: options.aggregateChannels ? knex.raw('facet scenes.studio_id as studios_facet distinct id order by count(*) desc limit ?', [aggSize]) : null, studiosFacet: options.aggregateChannels ? knex.raw('facet scenes.studio_id as studios_facet distinct id order by count(*) desc limit ?', [aggSize]) : null,
maxMatches: config.database.manticore.maxMatches, maxMatches: config.database.manticore.maxMatches,
@@ -606,13 +603,10 @@ async function queryManticoreSql(filters, options, _reqUser) {
const results = await utilsApi.sql(curatedSqlQuery); const results = await utilsApi.sql(curatedSqlQuery);
// console.log(util.inspect(results, null, Infinity)); const years = curateFacet(results, 'years_facet');
const years = curateFacet(results, 'years_facet', 'count(*)');
const actorIds = curateFacet(results, 'actors_facet'); const actorIds = curateFacet(results, 'actors_facet');
const tagIds = curateFacet(results, 'tags_facet'); const tagIds = curateFacet(results, 'tags_facet');
// const actorTagIds = curateFacet(results, 'actor_tags_facet'); const actorTagIds = curateFacet(results, 'actor_tags_facet');
const actorTagIds = [];
const channelIds = curateFacet(results, 'channels_facet'); const channelIds = curateFacet(results, 'channels_facet');
const studioIds = curateFacet(results, 'studios_facet'); const studioIds = curateFacet(results, 'studios_facet');