1
0
Fork 1
mirror of https://example.com synced 2024-11-22 07:16:39 +09:00

perf (backend): improved post search with alt text

Co-authored-by: naskya <m@naskya.net>
This commit is contained in:
sup39 2024-03-13 18:03:08 +09:00 committed by naskya
parent bc5f233b9a
commit e6e8aac224
Signed by: naskya
GPG key ID: 712D413B3A9FED5C

View file

@ -98,20 +98,16 @@ export default define(meta, paramDef, async (ps, me) => {
if (ps.searchCwAndAlt) {
query.andWhere(
new Brackets((qb) => {
qb.where("note.text &@~ :q", { q })
.orWhere("note.cw &@~ :q", { q })
.orWhere(
`EXISTS (
SELECT FROM "drive_file"
WHERE
comment &@~ :q
AND
drive_file."id" = ANY(note."fileIds")
)`,
{ q },
);
}),
`"note"."id" IN (
SELECT "id" FROM "note" WHERE "note"."text" &@~ :q
UNION
SELECT "id" FROM "note" WHERE "note"."cw" &@~ :q
UNION
SELECT "note_file"."noteId" FROM "note_file"
INNER JOIN "drive_file" ON "drive_file"."id" = "note_file"."fileId"
WHERE "drive_file"."comment" &@~ :q
)`,
{ q },
);
} else {
query.andWhere("note.text &@~ :q", { q });