mirror of
https://github.com/KevinMidboe/immich.git
synced 2025-10-29 17:40:28 +00:00
fix(server): people sorting (#3713)
This commit is contained in:
@@ -51,16 +51,22 @@ export class PersonRepository implements IPersonRepository {
|
||||
}
|
||||
|
||||
getAll(userId: string, options?: PersonSearchOptions): Promise<PersonEntity[]> {
|
||||
return this.personRepository
|
||||
const queryBuilder = this.personRepository
|
||||
.createQueryBuilder('person')
|
||||
.leftJoin('person.faces', 'face')
|
||||
.where('person.ownerId = :userId', { userId })
|
||||
.orderBy('COUNT(face.assetId)', 'DESC')
|
||||
.orderBy('person.isHidden', 'ASC')
|
||||
.addOrderBy("NULLIF(person.name, '') IS NULL", 'ASC')
|
||||
.addOrderBy('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)
|
||||
.getMany();
|
||||
.limit(500);
|
||||
if (!options?.withHidden) {
|
||||
queryBuilder.andWhere('person.isHidden = false');
|
||||
}
|
||||
|
||||
return queryBuilder.getMany();
|
||||
}
|
||||
|
||||
getAllWithoutFaces(): Promise<PersonEntity[]> {
|
||||
|
||||
Reference in New Issue
Block a user