Restructured the note query once again
ci/woodpecker/tag/ociImageTag Pipeline was successful Details

This commit is contained in:
Natty 2023-12-28 04:48:41 +01:00
parent f9fc12f2fd
commit 05a228d8ec
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
1 changed files with 8 additions and 10 deletions

View File

@ -67,8 +67,13 @@ export default define(meta, paramDef, async (ps, me) => {
throw e; throw e;
}); });
const cte = const cte = makePaginationQuery(
Notes.createQueryBuilder("n") Notes.createQueryBuilder("n"),
ps.sinceId,
ps.untilId,
ps.sinceDate,
ps.untilDate,
)
.select(`"n"."id"`, "id") .select(`"n"."id"`, "id")
.andWhere("n.userId = :userId", { userId: user.id }); .andWhere("n.userId = :userId", { userId: user.id });
@ -82,7 +87,6 @@ export default define(meta, paramDef, async (ps, me) => {
if (ps.includeMyRenotes === false) { if (ps.includeMyRenotes === false) {
cte.andWhere( cte.andWhere(
new Brackets((qb) => { new Brackets((qb) => {
qb.orWhere("n.userId != :userId", { userId: user.id });
qb.orWhere("n.renoteId IS NULL"); qb.orWhere("n.renoteId IS NULL");
qb.orWhere("n.text IS NOT NULL"); qb.orWhere("n.text IS NOT NULL");
qb.orWhere("n.fileIds != '{}'"); qb.orWhere("n.fileIds != '{}'");
@ -93,13 +97,7 @@ export default define(meta, paramDef, async (ps, me) => {
); );
} }
const query = makePaginationQuery( const query = Notes.createQueryBuilder("note")
Notes.createQueryBuilder("note"),
ps.sinceId,
ps.untilId,
ps.sinceDate,
ps.untilDate,
)
.addCommonTableExpression(cte, "noteCte"); .addCommonTableExpression(cte, "noteCte");
query.andWhere(`"note"."id" IN` + query.subQuery() query.andWhere(`"note"."id" IN` + query.subQuery()