mirror of
https://github.com/immich-app/immich
synced 2025-11-14 17:36:12 +00:00
fix(server): incorrect number of assets for a person (#7602)
* fix: incorrect number of assets * fix: tests * pr feedback * fix: e2e test * fix: e2e test * fix: e2e test * feat: more tests
This commit is contained in:
parent
5bc13c49a4
commit
6ab404597c
3 changed files with 60 additions and 20 deletions
|
|
@ -171,16 +171,17 @@ export class PersonRepository implements IPersonRepository {
|
|||
|
||||
@GenerateSql({ params: [DummyValue.UUID] })
|
||||
async getStatistics(personId: string): Promise<PersonStatistics> {
|
||||
const items = await this.assetFaceRepository
|
||||
.createQueryBuilder('face')
|
||||
.leftJoin('face.asset', 'asset')
|
||||
.where('face.personId = :personId', { personId })
|
||||
.andWhere('asset.isArchived = false')
|
||||
.andWhere('asset.deletedAt IS NULL')
|
||||
.andWhere('asset.livePhotoVideoId IS NULL')
|
||||
.select('COUNT(DISTINCT(asset.id))', 'count')
|
||||
.getRawOne();
|
||||
return {
|
||||
assets: await this.assetFaceRepository
|
||||
.createQueryBuilder('face')
|
||||
.leftJoin('face.asset', 'asset')
|
||||
.where('face.personId = :personId', { personId })
|
||||
.andWhere('asset.isArchived = false')
|
||||
.andWhere('asset.deletedAt IS NULL')
|
||||
.andWhere('asset.livePhotoVideoId IS NULL')
|
||||
.distinct(true)
|
||||
.getCount(),
|
||||
assets: items.count ?? 0,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -223,8 +224,8 @@ export class PersonRepository implements IPersonRepository {
|
|||
.getRawOne();
|
||||
|
||||
const result: PeopleStatistics = {
|
||||
total: items ? Number.parseInt(items.total) : 0,
|
||||
hidden: items ? Number.parseInt(items.hidden) : 0,
|
||||
total: items.total ?? 0,
|
||||
hidden: items.hidden ?? 0,
|
||||
};
|
||||
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -224,8 +224,8 @@ LIMIT
|
|||
20
|
||||
|
||||
-- PersonRepository.getStatistics
|
||||
SELECT DISTINCT
|
||||
COUNT(DISTINCT ("face"."id")) AS "cnt"
|
||||
SELECT
|
||||
COUNT(DISTINCT ("asset"."id")) AS "count"
|
||||
FROM
|
||||
"asset_faces" "face"
|
||||
LEFT JOIN "assets" "asset" ON "asset"."id" = "face"."assetId"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue