diff --git a/src/scenes.js b/src/scenes.js index 48affba..4534c6e 100644 --- a/src/scenes.js +++ b/src/scenes.js @@ -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);