Skip to content

Commit 4f725b9

Browse files
authored
fix(server): do not count deleted assets for album summary (#15668)
fixes #15645 fixes #15646
1 parent 64b92cb commit 4f725b9

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

e2e/src/api/specs/album.e2e-spec.ts

+20
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,26 @@ describe('/albums', () => {
362362
shared: true,
363363
});
364364
});
365+
366+
it('should not count trashed assets', async () => {
367+
await utils.deleteAssets(user1.accessToken, [user1Asset2.id]);
368+
369+
const { status, body } = await request(app)
370+
.get(`/albums/${user2Albums[0].id}?withoutAssets=true`)
371+
.set('Authorization', `Bearer ${user1.accessToken}`);
372+
373+
expect(status).toBe(200);
374+
expect(body).toEqual({
375+
...user2Albums[0],
376+
assets: [],
377+
assetCount: 1,
378+
lastModifiedAssetTimestamp: expect.any(String),
379+
endDate: expect.any(String),
380+
startDate: expect.any(String),
381+
albumUsers: expect.any(Array),
382+
shared: true,
383+
});
384+
});
365385
});
366386

367387
describe('GET /albums/statistics', () => {

server/src/queries/album.repository.sql

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ from
210210
left join "assets" on "assets"."id" = "album_assets"."assetsId"
211211
where
212212
"albums"."id" in ($1)
213+
and "assets"."deletedAt" is null
213214
group by
214215
"albums"."id"
215216

server/src/repositories/album.repository.ts

+1
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ export class AlbumRepository implements IAlbumRepository {
126126
.select((eb) => eb.fn.max('assets.fileCreatedAt').as('endDate'))
127127
.select((eb) => eb.fn.count('assets.id').as('assetCount'))
128128
.where('albums.id', 'in', ids)
129+
.where('assets.deletedAt', 'is', null)
129130
.groupBy('albums.id')
130131
.execute();
131132

0 commit comments

Comments
 (0)