From ba9b9353bc6fb33ea961c5f6c7e1367eb6dd6d1e Mon Sep 17 00:00:00 2001 From: Mert <101130780+mertalev@users.noreply.github.com> Date: Tue, 3 Dec 2024 15:04:42 -0500 Subject: [PATCH] fix(server): show people without thumbnails (#14460) * show people without thumbnails * redundant clause * updated sql --- server/src/queries/person.repository.sql | 8 ++------ server/src/repositories/person.repository.ts | 7 ++----- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/server/src/queries/person.repository.sql b/server/src/queries/person.repository.sql index 5616559d7d06d..a7e683fca1e72 100644 --- a/server/src/queries/person.repository.sql +++ b/server/src/queries/person.repository.sql @@ -20,13 +20,12 @@ SELECT "person"."isHidden" AS "person_isHidden" FROM "person" "person" - LEFT JOIN "asset_faces" "face" ON "face"."personId" = "person"."id" + INNER JOIN "asset_faces" "face" ON "face"."personId" = "person"."id" INNER JOIN "assets" "asset" ON "asset"."id" = "face"."assetId" AND ("asset"."deletedAt" IS NULL) WHERE "person"."ownerId" = $1 AND "asset"."isArchived" = false - AND "person"."thumbnailPath" != '' AND "person"."isHidden" = false GROUP BY "person"."id" @@ -257,15 +256,12 @@ SELECT ) AS "hidden" FROM "person" "person" - LEFT JOIN "asset_faces" "face" ON "face"."personId" = "person"."id" + INNER JOIN "asset_faces" "face" ON "face"."personId" = "person"."id" INNER JOIN "assets" "asset" ON "asset"."id" = "face"."assetId" AND ("asset"."deletedAt" IS NULL) WHERE "person"."ownerId" = $1 AND "asset"."isArchived" = false - AND "person"."thumbnailPath" != '' -HAVING - COUNT("face"."assetId") != 0 -- PersonRepository.getFacesByIds SELECT diff --git a/server/src/repositories/person.repository.ts b/server/src/repositories/person.repository.ts index 56116d7b3bf97..81958d269d27b 100644 --- a/server/src/repositories/person.repository.ts +++ b/server/src/repositories/person.repository.ts @@ -86,7 +86,7 @@ export class PersonRepository implements IPersonRepository { getAllForUser(pagination: PaginationOptions, userId: string, options?: PersonSearchOptions): Paginated { const queryBuilder = this.personRepository .createQueryBuilder('person') - .leftJoin('person.faces', 'face') + .innerJoin('person.faces', 'face') .where('person.ownerId = :userId', { userId }) .innerJoin('face.asset', 'asset') .andWhere('asset.isArchived = false') @@ -95,7 +95,6 @@ export class PersonRepository implements IPersonRepository { .addOrderBy('COUNT(face.assetId)', 'DESC') .addOrderBy("NULLIF(person.name, '')", 'ASC', 'NULLS LAST') .addOrderBy('person.createdAt') - .andWhere("person.thumbnailPath != ''") .having("person.name != '' OR COUNT(face.assetId) >= :faces", { faces: options?.minimumFaceCount || 1 }) .groupBy('person.id'); if (!options?.withHidden) { @@ -232,14 +231,12 @@ export class PersonRepository implements IPersonRepository { async getNumberOfPeople(userId: string): Promise { const items = await this.personRepository .createQueryBuilder('person') - .leftJoin('person.faces', 'face') + .innerJoin('person.faces', 'face') .where('person.ownerId = :userId', { userId }) .innerJoin('face.asset', 'asset') .andWhere('asset.isArchived = false') - .andWhere("person.thumbnailPath != ''") .select('COUNT(DISTINCT(person.id))', 'total') .addSelect('COUNT(DISTINCT(person.id)) FILTER (WHERE person.isHidden = true)', 'hidden') - .having('COUNT(face.assetId) != 0') .getRawOne(); if (items == undefined) {