fix(server): people count doesn't match array

pull/24453/head
Yaros 2025-12-08 13:06:05 +01:00
parent 1e1cf0d1fe
commit a53ba9381f
2 changed files with 11 additions and 2 deletions

View File

@ -358,7 +358,7 @@ export class PersonRepository {
}
@GenerateSql({ params: [DummyValue.UUID] })
getNumberOfPeople(userId: string) {
getNumberOfPeople(userId: string, options?: PersonSearchOptions) {
const zero = sql.lit(0);
return this.db
.selectFrom('person')
@ -368,6 +368,12 @@ export class PersonRepository {
.selectFrom('asset_face')
.whereRef('asset_face.personId', '=', 'person.id')
.where('asset_face.deletedAt', 'is', null)
.having((eb) =>
eb.or([
eb('person.name', '!=', ''),
eb((innerEb) => innerEb.fn.count('asset_face.assetId'), '>=', options?.minimumFaceCount || 1),
]),
)
.where((eb) =>
eb.exists((eb) =>
eb

View File

@ -67,7 +67,10 @@ export class PersonService extends BaseService {
withHidden,
closestFaceAssetId,
});
const { total, hidden } = await this.personRepository.getNumberOfPeople(auth.user.id);
const { total, hidden } = await this.personRepository.getNumberOfPeople(auth.user.id, {
minimumFaceCount: machineLearning.facialRecognition.minFaces,
withHidden,
});
return {
people: items.map((person) => mapPerson(person)),