Compare commits

...

3 Commits

Author SHA1 Message Date
Yaros
f1111bbc62 chore: adjusted e2e tests 2025-12-08 16:47:36 +01:00
Yaros
6d8c166d86 chore: update sql query file 2025-12-08 15:32:36 +01:00
Yaros
a53ba9381f fix(server): people count doesn't match array 2025-12-08 13:06:05 +01:00
4 changed files with 21 additions and 7 deletions

View File

@@ -122,7 +122,7 @@ describe('/people', () => {
expect(status).toBe(200);
expect(body).toEqual({
hasNextPage: false,
total: 11,
total: 10,
hidden: 1,
people: [
expect.objectContaining({ name: 'Freddy' }),
@@ -144,7 +144,7 @@ describe('/people', () => {
expect(status).toBe(200);
expect(body.hasNextPage).toBe(false);
expect(body.total).toBe(11); // All persons
expect(body.total).toBe(10); // All persons
expect(body.hidden).toBe(1); // 'hidden_person'
const people = body.people as PersonResponseDto[];
@@ -170,7 +170,7 @@ describe('/people', () => {
expect(status).toBe(200);
expect(body).toEqual({
hasNextPage: false,
total: 11,
total: 10,
hidden: 1,
people: [
expect.objectContaining({ name: 'Freddy' }),
@@ -195,7 +195,7 @@ describe('/people', () => {
expect(status).toBe(200);
expect(body).toEqual({
hasNextPage: true,
total: 11,
total: 10,
hidden: 1,
people: [expect.objectContaining({ name: 'Alice' })],
});

View File

@@ -259,8 +259,13 @@ where
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
)
having
(
"person"."name" != $2
or count("asset_face"."assetId") >= $3
)
)
and "person"."ownerId" = $2
and "person"."ownerId" = $4
-- PersonRepository.refreshFaces
with

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)),