mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat: improve performance for GET /api/album & /api/album/:id (#17124)
* fix(server) optimize number of sql calls for GET /api/albums remove unnecessary join for getMetadataForIds remove separate call to getLastUpdatedAssetForAlbumId * fix(server) remove unnecessary getLastUpdatedAssetForAlbumId call for GET /api/album/:id also remove getLastUpdatedAssetForAlbumId query as it is no longer referenced * fix(server): correct lastModifiedAssetTimestamp return type + formatting and typing * chore(server): address type issue with tests found via npm:check tests & lint still pass before this commit.
This commit is contained in:
parent
238c151ac3
commit
09f4476f97
6 changed files with 71 additions and 51 deletions
|
|
@ -201,19 +201,23 @@ order by
|
|||
|
||||
-- AlbumRepository.getMetadataForIds
|
||||
select
|
||||
"albums"."id" as "albumId",
|
||||
min("assets"."localDateTime") as "startDate",
|
||||
max("assets"."localDateTime") as "endDate",
|
||||
"album_assets"."albumsId" as "albumId",
|
||||
min(
|
||||
("assets"."localDateTime" AT TIME ZONE 'UTC'::text)::date
|
||||
) as "startDate",
|
||||
max(
|
||||
("assets"."localDateTime" AT TIME ZONE 'UTC'::text)::date
|
||||
) as "endDate",
|
||||
max("assets"."updatedAt") as "lastModifiedAssetTimestamp",
|
||||
count("assets"."id")::int as "assetCount"
|
||||
from
|
||||
"albums"
|
||||
inner join "albums_assets_assets" as "album_assets" on "album_assets"."albumsId" = "albums"."id"
|
||||
inner join "assets" on "assets"."id" = "album_assets"."assetsId"
|
||||
"assets"
|
||||
inner join "albums_assets_assets" as "album_assets" on "album_assets"."assetsId" = "assets"."id"
|
||||
where
|
||||
"albums"."id" in ($1)
|
||||
"album_assets"."albumsId" in ($1)
|
||||
and "assets"."deletedAt" is null
|
||||
group by
|
||||
"albums"."id"
|
||||
"album_assets"."albumsId"
|
||||
|
||||
-- AlbumRepository.getOwned
|
||||
select
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue