mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-25 03:17:38 -07:00
[backend] Improve postgres FTS mention filter query
This commit is contained in:
parent
292e537dc7
commit
b7a5c192d8
1 changed files with 6 additions and 4 deletions
|
@ -97,13 +97,15 @@ function fromFilterInverse(query: SelectQueryBuilder<any>, filter: string, id: n
|
|||
|
||||
function mentionFilter(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
||||
const userQuery = generateUserSubquery(filter, id);
|
||||
query.andWhere(`note.mentions @> array[(${userQuery.getQuery()})]`);
|
||||
query.addCommonTableExpression(userQuery.getQuery(), `cte_${id}`, { materialized: true })
|
||||
query.andWhere(`note.mentions @> array[(SELECT * FROM cte_${id})]::varchar[]`);
|
||||
query.setParameters(userQuery.getParameters());
|
||||
}
|
||||
|
||||
function mentionFilterInverse(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
||||
const userQuery = generateUserSubquery(filter, id);
|
||||
query.andWhere(`NOT (note.mentions @> array[(${userQuery.getQuery()})])`);
|
||||
query.addCommonTableExpression(userQuery.getQuery(), `cte_${id}`, { materialized: true })
|
||||
query.andWhere(`NOT (note.mentions @> array[(SELECT * FROM cte_${id})]::varchar[])`);
|
||||
query.setParameters(userQuery.getParameters());
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue