1
0
mirror of https://github.com/immich-app/immich.git synced 2025-02-04 18:35:31 +02:00

fix(server): Fix for sorting faces during merging (#15571)

* Fix for sorting faces

* Put uneccessary orderBy in if statement
This commit is contained in:
Lukas 2025-01-23 21:33:24 -05:00 committed by GitHub
parent a07ae9b5b2
commit 065d885ca0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -133,10 +133,6 @@ export class PersonRepository implements IPersonRepository {
)
.where('person.ownerId', '=', userId)
.orderBy('person.isHidden', 'asc')
.orderBy(sql`NULLIF(person.name, '') is null`, 'asc')
.orderBy((eb) => eb.fn.count('asset_faces.assetId'), 'desc')
.orderBy(sql`NULLIF(person.name, '')`, sql`asc nulls last`)
.orderBy('person.createdAt')
.having((eb) =>
eb.or([
eb('person.name', '!=', ''),
@ -161,6 +157,13 @@ export class PersonRepository implements IPersonRepository {
),
),
)
.$if(!options?.closestFaceAssetId, (qb) =>
qb
.orderBy(sql`NULLIF(person.name, '') is null`, 'asc')
.orderBy((eb) => eb.fn.count('asset_faces.assetId'), 'desc')
.orderBy(sql`NULLIF(person.name, '')`, sql`asc nulls last`)
.orderBy('person.createdAt'),
)
.$if(!options?.withHidden, (qb) => qb.where('person.isHidden', '=', false))
.offset(pagination.skip ?? 0)
.limit(pagination.take + 1)