1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-29 11:24:37 +02:00

fix(server): sort un-named faces in query (#3662)

This commit is contained in:
shalong-tanwen 2023-08-14 21:39:26 +05:30 committed by GitHub
parent f55c80eadf
commit b1b215f083
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 3 deletions

View File

@ -27,10 +27,8 @@ export class PersonService {
async getAll(authUser: AuthUserDto, dto: PersonSearchDto): Promise<PeopleResponseDto> {
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));

View File

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