mirror of
				https://github.com/immich-app/immich.git
				synced 2025-10-31 10:37:11 -04:00 
			
		
		
		
	fix(server): do not count deleted assets for album summary (#15668)
fixes #15645 fixes #15646
This commit is contained in:
		
							parent
							
								
									64b92cb24c
								
							
						
					
					
						commit
						4f725b95e1
					
				| @ -362,6 +362,26 @@ describe('/albums', () => { | |||||||
|         shared: true, |         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', () => { |   describe('GET /albums/statistics', () => { | ||||||
|  | |||||||
| @ -210,6 +210,7 @@ from | |||||||
|   left join "assets" on "assets"."id" = "album_assets"."assetsId" |   left join "assets" on "assets"."id" = "album_assets"."assetsId" | ||||||
| where | where | ||||||
|   "albums"."id" in ($1) |   "albums"."id" in ($1) | ||||||
|  |   and "assets"."deletedAt" is null | ||||||
| group by | group by | ||||||
|   "albums"."id" |   "albums"."id" | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -126,6 +126,7 @@ export class AlbumRepository implements IAlbumRepository { | |||||||
|       .select((eb) => eb.fn.max('assets.fileCreatedAt').as('endDate')) |       .select((eb) => eb.fn.max('assets.fileCreatedAt').as('endDate')) | ||||||
|       .select((eb) => eb.fn.count('assets.id').as('assetCount')) |       .select((eb) => eb.fn.count('assets.id').as('assetCount')) | ||||||
|       .where('albums.id', 'in', ids) |       .where('albums.id', 'in', ids) | ||||||
|  |       .where('assets.deletedAt', 'is', null) | ||||||
|       .groupBy('albums.id') |       .groupBy('albums.id') | ||||||
|       .execute(); |       .execute(); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user