High performance self-hosted photo and video management solution.
TypeScript backup-toolfluttergoogle-photosgoogle-photos-alternativejavascriptmobile-appnestjsnodejsphoto-galleryphotosphotos-managementself-hostedsveltesveltekittypescriptvideos
fix(server): do not count deleted assets for album summary (#15668)
Carsten Otto4f725b95e1df
diff --git a/e2e/src/api/specs/album.e2e-spec.ts b/e2e/src/api/specs/album.e2e-spec.tsindex 5b40234e8d..1d142ac468 100644--- a/e2e/src/api/specs/album.e2e-spec.ts+++ b/e2e/src/api/specs/album.e2e-spec.ts@@ -362,6 +362,26 @@ describe('/albums', () => {shared: true,});});++ it('should not count trashed assets', async () => {+ await utils.deleteAssets(user1.accessToken, [user1Asset2.id]);++ const { status, body } = await request(app)+ .get(`/albums/${user2Albums[0].id}?withoutAssets=true`)+ .set('Authorization', `Bearer ${user1.accessToken}`);++ expect(status).toBe(200);+ expect(body).toEqual({+ ...user2Albums[0],+ assets: [],+ assetCount: 1,+ lastModifiedAssetTimestamp: expect.any(String),+ endDate: expect.any(String),+ startDate: expect.any(String),+ albumUsers: expect.any(Array),+ shared: true,+ });+ });});describe('GET /albums/statistics', () => {diff --git a/server/src/queries/album.repository.sql b/server/src/queries/album.repository.sqlindex 48dc4dda4e..b982ea2cff 100644--- a/server/src/queries/album.repository.sql+++ b/server/src/queries/album.repository.sql@@ -210,6 +210,7 @@ fromleft join "assets" on "assets"."id" = "album_assets"."assetsId"where"albums"."id" in ($1)+ and "assets"."deletedAt" is nullgroup by"albums"."id"diff --git a/server/src/repositories/album.repository.ts b/server/src/repositories/album.repository.tsindex d3b696169b..c6e01b532e 100644--- a/server/src/repositories/album.repository.ts+++ b/server/src/repositories/album.repository.ts@@ -126,6 +126,7 @@ export class AlbumRepository implements IAlbumRepository {.select((eb) => eb.fn.max('assets.fileCreatedAt').as('endDate')).select((eb) => eb.fn.count('assets.id').as('assetCount')).where('albums.id', 'in', ids)+ .where('assets.deletedAt', 'is', null).groupBy('albums.id').execute();