mirror of
https://iceshrimp.dev/limepotato/jormungandr-bite.git
synced 2024-11-21 17:37:29 -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,14 +97,16 @@ 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.setParameters(userQuery.getParameters());
|
||||
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.setParameters(userQuery.getParameters());
|
||||
query.addCommonTableExpression(userQuery.getQuery(), `cte_${id}`, { materialized: true })
|
||||
query.andWhere(`NOT (note.mentions @> array[(SELECT * FROM cte_${id})]::varchar[])`);
|
||||
query.setParameters(userQuery.getParameters());
|
||||
}
|
||||
|
||||
function replyFilter(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
||||
|
|
Loading…
Reference in a new issue