Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(server): update person count sql
Browse files Browse the repository at this point in the history
jedi04 committed Oct 9, 2024

Unverified

This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
1 parent add02b7 commit 7977637
Showing 1 changed file with 21 additions and 13 deletions.
34 changes: 21 additions & 13 deletions server/src/queries/person.repository.sql
Original file line number Diff line number Diff line change
@@ -250,22 +250,30 @@ WHERE

-- PersonRepository.getNumberOfPeople
SELECT
COUNT(DISTINCT ("person"."id")) AS "total",
COUNT(DISTINCT ("person"."id")) FILTER (
COUNT(person.id) AS "total",
COUNT(person.id) FILTER (
WHERE
"person"."isHidden" = true
person."isHidden" = true
) AS "hidden"
FROM
"person" "person"
LEFT 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
(
SELECT
"person"."id" AS "id",
"person"."isHidden" AS "isHidden"
FROM
"person" "person"
LEFT 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" != ''
GROUP BY
"person"."id"
HAVING
COUNT("face"."assetId") >= $2
) "person"

-- PersonRepository.getFacesByIds
SELECT

0 comments on commit 7977637

Please sign in to comment.