Fixed MVA selection in scene query.

This commit is contained in:
DebaucheryLibrarian 2024-03-17 17:41:31 +01:00
parent 7a3fb84cf6
commit 27c17e9a3c
1 changed files with 12 additions and 8 deletions

View File

@ -406,9 +406,13 @@ async function queryManticoreSql(filters, options, _reqUser) {
builder.whereRaw('match(\'@!title :query:\', scenes)', { query: filters.query });
}
if (filters.tagIds?.length > 0) {
builder.whereIn('any(tag_ids)', filters.tagIds);
}
filters.tagIds?.forEach((tagId) => {
builder.where('any(tag_ids)', tagId);
});
filters.actorIds?.forEach((actorId) => {
builder.where('any(actor_ids)', actorId);
});
if (filters.entityId) {
builder.where((whereBuilder) => {
@ -418,10 +422,6 @@ async function queryManticoreSql(filters, options, _reqUser) {
});
}
if (filters.actorIds?.length > 0) {
builder.whereIn('any(actor_ids)', filters.actorIds);
}
if (typeof filters.isShowcased === 'boolean') {
builder.where('is_showcased', filters.isShowcased);
}
@ -468,11 +468,15 @@ async function queryManticoreSql(filters, options, _reqUser) {
maxQueryTime: config.database.manticore.maxQueryTime,
}).toString();
// manticore does not seem to accept table.column syntax if 'table' is primary (yet), crude work-around
// manticore does not seem to accept table.column syntax if 'table' is primary (yet?), crude work-around
const curatedSqlQuery = filters.stashId
? sqlQuery
: sqlQuery.replace(/scenes\./g, '');
if (process.env.NODE_ENV === 'development') {
console.log(curatedSqlQuery);
}
const results = await utilsApi.sql(curatedSqlQuery);
// console.log(results);