1
0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2024-12-28 22:51:59 +00:00

fix(server): increase person search limit (#12619)

This commit is contained in:
Jason Rasmussen 2024-09-13 12:33:16 -04:00 committed by GitHub
parent a373d50c31
commit c717fd2131
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 3 additions and 11 deletions

View file

@ -215,19 +215,14 @@ SELECT
"person"."isHidden" AS "person_isHidden" "person"."isHidden" AS "person_isHidden"
FROM FROM
"person" "person" "person" "person"
LEFT JOIN "asset_faces" "face" ON "face"."personId" = "person"."id"
WHERE WHERE
"person"."ownerId" = $1 "person"."ownerId" = $1
AND ( AND (
LOWER("person"."name") LIKE $2 LOWER("person"."name") LIKE $2
OR LOWER("person"."name") LIKE $3 OR LOWER("person"."name") LIKE $3
) )
GROUP BY
"person"."id"
ORDER BY
COUNT("face"."assetId") DESC
LIMIT LIMIT
20 1000
-- PersonRepository.getDistinctNames -- PersonRepository.getDistinctNames
SELECT DISTINCT SELECT DISTINCT

View file

@ -184,14 +184,11 @@ export class PersonRepository implements IPersonRepository {
getByName(userId: string, personName: string, { withHidden }: PersonNameSearchOptions): Promise<PersonEntity[]> { getByName(userId: string, personName: string, { withHidden }: PersonNameSearchOptions): Promise<PersonEntity[]> {
const queryBuilder = this.personRepository const queryBuilder = this.personRepository
.createQueryBuilder('person') .createQueryBuilder('person')
.leftJoin('person.faces', 'face')
.where( .where(
'person.ownerId = :userId AND (LOWER(person.name) LIKE :nameStart OR LOWER(person.name) LIKE :nameAnywhere)', 'person.ownerId = :userId AND (LOWER(person.name) LIKE :nameStart OR LOWER(person.name) LIKE :nameAnywhere)',
{ userId, nameStart: `${personName.toLowerCase()}%`, nameAnywhere: `% ${personName.toLowerCase()}%` }, { userId, nameStart: `${personName.toLowerCase()}%`, nameAnywhere: `% ${personName.toLowerCase()}%` },
) )
.groupBy('person.id') .limit(1000);
.orderBy('COUNT(face.assetId)', 'DESC')
.limit(20);
if (!withHidden) { if (!withHidden) {
queryBuilder.andWhere('person.isHidden = false'); queryBuilder.andWhere('person.isHidden = false');

View file

@ -93,7 +93,7 @@ export enum ActionQueryParameterValue {
MERGE = 'merge', MERGE = 'merge',
} }
export const maximumLengthSearchPeople: number = 20; export const maximumLengthSearchPeople = 1000;
// time to load the map before displaying the loading spinner // time to load the map before displaying the loading spinner
export const timeToLoadTheMap: number = 100; export const timeToLoadTheMap: number = 100;