fix(server): Return correct asset count in album (#5465)

* fix(server): Return correct asset count in album

* Update album.repository.sql

Add generated sql
This commit is contained in:
PyKen 2023-12-05 01:22:00 +09:00 committed by GitHub
parent bdbaa166d9
commit 1a63d3837e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View file

@ -76,7 +76,7 @@ export class AlbumRepository implements IAlbumRepository {
.select('album.id')
.addSelect('MIN(assets.fileCreatedAt)', 'start_date')
.addSelect('MAX(assets.fileCreatedAt)', 'end_date')
.addSelect('COUNT(album_assets.assetsId)', 'asset_count')
.addSelect('COUNT(assets.id)', 'asset_count')
.leftJoin('albums_assets_assets', 'album_assets', 'album_assets.albumsId = album.id')
.leftJoin('assets', 'assets', 'assets.id = album_assets.assetsId')
.where('album.id IN (:...ids)', { ids })

View file

@ -207,7 +207,7 @@ SELECT
"album"."id" AS "album_id",
MIN("assets"."fileCreatedAt") AS "start_date",
MAX("assets"."fileCreatedAt") AS "end_date",
COUNT("album_assets"."assetsId") AS "asset_count"
COUNT("assets"."id") AS "asset_count"
FROM
"albums" "album"
LEFT JOIN "albums_assets_assets" "album_assets" ON "album_assets"."albumsId" = "album"."id"