mirror of
https://iceshrimp.dev/crimekillz/trashposs
synced 2024-11-22 00:43:49 +01:00
[backend] Improve postgres FTS mention filter query
This commit is contained in:
parent
292e537dc7
commit
b7a5c192d8
@ -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 New Issue
Block a user