From b520955d0ea31b76d00695189d215f7db1814539 Mon Sep 17 00:00:00 2001 From: Mert <101130780+mertalev@users.noreply.github.com> Date: Sun, 17 Dec 2023 21:17:30 -0500 Subject: [PATCH] fix(server): add more conditions to smart search (#5806) * add more asset conditions * udpate sql --- server/src/infra/repositories/smart-info.repository.ts | 3 +++ server/src/infra/sql/smart.info.repository.sql | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/server/src/infra/repositories/smart-info.repository.ts b/server/src/infra/repositories/smart-info.repository.ts index 57aaa4d3c7..340ffa9990 100644 --- a/server/src/infra/repositories/smart-info.repository.ts +++ b/server/src/infra/repositories/smart-info.repository.ts @@ -56,6 +56,9 @@ export class SmartInfoRepository implements ISmartInfoRepository { .createQueryBuilder(AssetEntity, 'a') .innerJoin('a.smartSearch', 's') .where('a.ownerId = :ownerId') + .andWhere('a.isVisible = true') + .andWhere('a.isArchived = false') + .andWhere('a.fileCreatedAt < NOW()') .leftJoinAndSelect('a.exifInfo', 'e') .orderBy('s.embedding <=> :embedding') .setParameters({ ownerId, embedding: asVector(embedding) }) diff --git a/server/src/infra/sql/smart.info.repository.sql b/server/src/infra/sql/smart.info.repository.sql index 50cbfa71fc..c03168d879 100644 --- a/server/src/infra/sql/smart.info.repository.sql +++ b/server/src/infra/sql/smart.info.repository.sql @@ -66,7 +66,12 @@ FROM INNER JOIN "smart_search" "s" ON "s"."assetId" = "a"."id" LEFT JOIN "exif" "e" ON "e"."assetId" = "a"."id" WHERE - ("a"."ownerId" = $1) + ( + "a"."ownerId" = $1 + AND "a"."isVisible" = true + AND "a"."isArchived" = false + AND "a"."fileCreatedAt" < NOW() + ) AND ("a"."deletedAt" IS NULL) ORDER BY "s"."embedding" <= > $2 ASC