Skip to content

Commit

Permalink
fix(server): fix getByDayOfYear query (#14655)
Browse files Browse the repository at this point in the history
* fix(server): fix getByDayOfYear query

* generate sql
  • Loading branch information
alextran1502 authored Dec 11, 2024
1 parent 71b48b1 commit 0c03753
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
15 changes: 14 additions & 1 deletion server/src/queries/asset.repository.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/src/repositories/asset.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
)
Expand Down

0 comments on commit 0c03753

Please sign in to comment.