diff --git a/server/src/queries/asset.repository.sql b/server/src/queries/asset.repository.sql index f4b1b2fea1..4694cd20fc 100644 --- a/server/src/queries/asset.repository.sql +++ b/server/src/queries/asset.repository.sql @@ -71,7 +71,20 @@ FROM INNER JOIN "asset_files" "files" ON "files"."assetId" = "entity"."id" WHERE ( - "files"."type" = $1 + "entity"."ownerId" IN ($1) + AND "entity"."isVisible" = true + AND "entity"."isArchived" = false + AND EXTRACT( + DAY + FROM + "entity"."localDateTime" AT TIME ZONE 'UTC' + ) = $2 + AND EXTRACT( + MONTH + FROM + "entity"."localDateTime" AT TIME ZONE 'UTC' + ) = $3 + AND "files"."type" = $4 AND EXTRACT( YEAR FROM diff --git a/server/src/repositories/asset.repository.ts b/server/src/repositories/asset.repository.ts index b3066a37bc..33d1e2457e 100644 --- a/server/src/repositories/asset.repository.ts +++ b/server/src/repositories/asset.repository.ts @@ -92,7 +92,7 @@ export class AssetRepository implements IAssetRepository { ) .leftJoinAndSelect('entity.exifInfo', 'exifInfo') .innerJoinAndSelect('entity.files', 'files') - .where('files.type = :type', { type: AssetFileType.THUMBNAIL }) + .andWhere('files.type = :type', { type: AssetFileType.THUMBNAIL }) .andWhere( `EXTRACT(YEAR FROM CURRENT_DATE AT TIME ZONE 'UTC') - EXTRACT(YEAR FROM entity.localDateTime AT TIME ZONE 'UTC') > 0`, )