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,14 +97,16 @@ function fromFilterInverse(query: SelectQueryBuilder<any>, filter: string, id: n
|
||||||
|
|
||||||
function mentionFilter(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
function mentionFilter(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
||||||
const userQuery = generateUserSubquery(filter, id);
|
const userQuery = generateUserSubquery(filter, id);
|
||||||
query.andWhere(`note.mentions @> array[(${userQuery.getQuery()})]`);
|
query.addCommonTableExpression(userQuery.getQuery(), `cte_${id}`, { materialized: true })
|
||||||
query.setParameters(userQuery.getParameters());
|
query.andWhere(`note.mentions @> array[(SELECT * FROM cte_${id})]::varchar[]`);
|
||||||
|
query.setParameters(userQuery.getParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
function mentionFilterInverse(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
function mentionFilterInverse(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
||||||
const userQuery = generateUserSubquery(filter, id);
|
const userQuery = generateUserSubquery(filter, id);
|
||||||
query.andWhere(`NOT (note.mentions @> array[(${userQuery.getQuery()})])`);
|
query.addCommonTableExpression(userQuery.getQuery(), `cte_${id}`, { materialized: true })
|
||||||
query.setParameters(userQuery.getParameters());
|
query.andWhere(`NOT (note.mentions @> array[(SELECT * FROM cte_${id})]::varchar[])`);
|
||||||
|
query.setParameters(userQuery.getParameters());
|
||||||
}
|
}
|
||||||
|
|
||||||
function replyFilter(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
function replyFilter(query: SelectQueryBuilder<any>, filter: string, id: number) {
|
||||||
|
|
Loading…
Reference in a new issue