diff --git a/server/src/domain/person/person.service.ts b/server/src/domain/person/person.service.ts index 0758b5f2c9..0f66447f13 100644 --- a/server/src/domain/person/person.service.ts +++ b/server/src/domain/person/person.service.ts @@ -27,10 +27,8 @@ export class PersonService { async getAll(authUser: AuthUserDto, dto: PersonSearchDto): Promise { const people = await this.repository.getAll(authUser.id, { minimumFaceCount: 1 }); - const named = people.filter((person) => !!person.name); - const unnamed = people.filter((person) => !person.name); - const persons: PersonResponseDto[] = [...named, ...unnamed] + const persons: PersonResponseDto[] = people // with thumbnails .filter((person) => !!person.thumbnailPath) .map((person) => mapPerson(person)); diff --git a/server/src/infra/repositories/person.repository.ts b/server/src/infra/repositories/person.repository.ts index db4ccff06b..8595484365 100644 --- a/server/src/infra/repositories/person.repository.ts +++ b/server/src/infra/repositories/person.repository.ts @@ -56,6 +56,7 @@ export class PersonRepository implements IPersonRepository { .leftJoin('person.faces', 'face') .where('person.ownerId = :userId', { userId }) .orderBy('COUNT(face.assetId)', 'DESC') + .addOrderBy("NULLIF(person.name, '')", 'ASC', 'NULLS LAST') .having('COUNT(face.assetId) >= :faces', { faces: options?.minimumFaceCount || 1 }) .groupBy('person.id') .limit(500)