Skip to content

High performance self-hosted photo and video management solution.

fix: include unamed people in otherPeople (#32237)

Jason Rasmussen9971dade1b2d
diff --git a/server/src/queries/person.repository.sql b/server/src/queries/person.repository.sql
index 4fc551f37c..7eb7c3bd19 100644
--- a/server/src/queries/person.repository.sql
+++ b/server/src/queries/person.repository.sql
@@ -184,10 +184,6 @@ select
and "person_user"."sharedWithId" = $2
where
"other"."personGroupId" = "person_group"."id"
- and (
- "other"."birthDate" is not null
- or "other"."name" != $3
- )
) as agg
) as "otherPeople",
(
@@ -209,7 +205,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person_group"."id"
- and "person_user"."sharedWithId" = $4
+ and "person_user"."sharedWithId" = $3
order by
"user"."name"
) as agg
@@ -233,7 +229,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person_group"."id"
- and "person_user"."sharedById" = $5
+ and "person_user"."sharedById" = $4
order by
"user"."name"
) as agg
@@ -242,7 +238,7 @@ from
"similarity_threshold",
"person_group"
inner join "person" as "owned" on "owned"."personGroupId" = "person_group"."id"
- and "owned"."ownerId" = $6
+ and "owned"."ownerId" = $5
inner join "asset_face" on "asset_face"."personGroupId" = "person_group"."id"
and "asset_face"."deletedAt" is null
and "asset_face"."isVisible" is true
@@ -250,7 +246,7 @@ from
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
and (
- "asset"."ownerId" = any ($7::uuid[])
+ "asset"."ownerId" = any ($6::uuid[])
or exists (
select
1 as "exists"
@@ -259,13 +255,13 @@ from
inner join "album" on "album"."id" = "album_asset"."albumId"
and "album"."deletedAt" is null
inner join "album_user" on "album_user"."albumId" = "album"."id"
- and "album_user"."userId" = $8::uuid
+ and "album_user"."userId" = $7::uuid
where
"album_asset"."assetId" = "asset"."id"
)
)
where
- "owned"."isHidden" = $9
+ "owned"."isHidden" = $8
and 1 = 1
group by
"person_group"."id",
@@ -273,7 +269,7 @@ group by
"owned"."personGroupId"
having
(
- "owned"."name" != $10
+ "owned"."name" != $9
or count("asset"."id") >= COALESCE(
(
SELECT
@@ -281,7 +277,7 @@ having
FROM
user_metadata
WHERE
- "userId" = $11
+ "userId" = $10
AND key = 'preferences'
),
'3'
@@ -295,9 +291,9 @@ order by
NULLIF("owned"."name", '') asc nulls last,
"owned"."createdAt"
limit
- $12
+ $11
offset
- $13
+ $12
-- PersonRepository.getAllWithoutFaces
select
@@ -344,10 +340,6 @@ select
and "person_user"."sharedWithId" = $1
where
"other"."personGroupId" = "person"."personGroupId"
- and (
- "other"."birthDate" is not null
- or "other"."name" != $2
- )
) as agg
) as "otherPeople",
(
@@ -369,7 +361,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedWithId" = $3
+ and "person_user"."sharedWithId" = $2
order by
"user"."name"
) as agg
@@ -393,7 +385,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedById" = $4
+ and "person_user"."sharedById" = $3
order by
"user"."name"
) as agg
@@ -402,15 +394,15 @@ select
"person"
where
"person"."personGroupId" = "asset_face"."personGroupId"
- and "person"."ownerId" = $5
+ and "person"."ownerId" = $4
) as obj
) as "person"
from
"asset_face"
where
- "asset_face"."assetId" = $6
+ "asset_face"."assetId" = $5
and "asset_face"."deletedAt" is null
- and "asset_face"."isVisible" = $7
+ and "asset_face"."isVisible" = $6
order by
"asset_face"."boundingBoxX1" asc
@@ -441,10 +433,6 @@ select
and "person_user"."sharedWithId" = $1
where
"other"."personGroupId" = "person"."personGroupId"
- and (
- "other"."birthDate" is not null
- or "other"."name" != $2
- )
) as agg
) as "otherPeople",
(
@@ -466,7 +454,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedWithId" = $3
+ and "person_user"."sharedWithId" = $2
order by
"user"."name"
) as agg
@@ -490,7 +478,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedById" = $4
+ and "person_user"."sharedById" = $3
order by
"user"."name"
) as agg
@@ -499,13 +487,13 @@ select
"person"
where
"person"."personGroupId" = "asset_face"."personGroupId"
- and "person"."ownerId" = $5
+ and "person"."ownerId" = $4
) as obj
) as "person"
from
"asset_face"
where
- "asset_face"."id" = $6
+ "asset_face"."id" = $5
and "asset_face"."deletedAt" is null
-- PersonRepository.getFaceForFacialRecognitionJob
@@ -621,10 +609,6 @@ select
and "person_user"."sharedWithId" = $2
where
"other"."personGroupId" = "person_group"."id"
- and (
- "other"."birthDate" is not null
- or "other"."name" != $3
- )
) as agg
) as "otherPeople",
(
@@ -646,7 +630,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person_group"."id"
- and "person_user"."sharedWithId" = $4
+ and "person_user"."sharedWithId" = $3
order by
"user"."name"
) as agg
@@ -670,7 +654,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person_group"."id"
- and "person_user"."sharedById" = $5
+ and "person_user"."sharedById" = $4
order by
"user"."name"
) as agg
@@ -678,7 +662,7 @@ select
from
"person_group"
where
- "person_group"."id" = $6
+ "person_group"."id" = $5
and exists (
select
"person"."ownerId"
@@ -686,7 +670,7 @@ where
"person"
where
"person"."personGroupId" = "person_group"."id"
- and "person"."ownerId" = $7
+ and "person"."ownerId" = $6
)
-- PersonRepository.getByGroupId
@@ -709,10 +693,6 @@ select
and "person_user"."sharedWithId" = $1
where
"other"."personGroupId" = "person"."personGroupId"
- and (
- "other"."birthDate" is not null
- or "other"."name" != $2
- )
) as agg
) as "otherPeople",
(
@@ -734,7 +714,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedWithId" = $3
+ and "person_user"."sharedWithId" = $2
order by
"user"."name"
) as agg
@@ -758,7 +738,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedById" = $4
+ and "person_user"."sharedById" = $3
order by
"user"."name"
) as agg
@@ -766,8 +746,8 @@ select
from
"person"
where
- "person"."personGroupId" = $5
- and "person"."ownerId" = $6
+ "person"."personGroupId" = $4
+ and "person"."ownerId" = $5
-- PersonRepository.getForThumbnail
select
@@ -824,10 +804,6 @@ select
and "person_user"."sharedWithId" = $1
where
"other"."personGroupId" = "person"."personGroupId"
- and (
- "other"."birthDate" is not null
- or "other"."name" != $2
- )
) as agg
) as "otherPeople",
(
@@ -849,7 +825,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedWithId" = $3
+ and "person_user"."sharedWithId" = $2
order by
"user"."name"
) as agg
@@ -873,7 +849,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedById" = $4
+ and "person_user"."sharedById" = $3
order by
"user"."name"
) as agg
@@ -882,12 +858,12 @@ from
"similarity_threshold",
"person"
where
- "person"."ownerId" = $5
- and f_unaccent ("person"."name") %> f_unaccent ($6)
+ "person"."ownerId" = $4
+ and f_unaccent ("person"."name") %> f_unaccent ($5)
order by
- f_unaccent ("person"."name") <->>> f_unaccent ($7)
+ f_unaccent ("person"."name") <->>> f_unaccent ($6)
limit
- $8
+ $7
-- PersonRepository.getDistinctNames
select distinct
@@ -1187,10 +1163,6 @@ select
and "person_user"."sharedWithId" = $1
where
"other"."personGroupId" = "person"."personGroupId"
- and (
- "other"."birthDate" is not null
- or "other"."name" != $2
- )
) as agg
) as "otherPeople",
(
@@ -1212,7 +1184,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedWithId" = $3
+ and "person_user"."sharedWithId" = $2
order by
"user"."name"
) as agg
@@ -1236,7 +1208,7 @@ select
and "user"."deletedAt" is null
where
"person_user"."personGroupId" = "person"."personGroupId"
- and "person_user"."sharedById" = $4
+ and "person_user"."sharedById" = $3
order by
"user"."name"
) as agg
@@ -1245,14 +1217,14 @@ select
"person"
where
"person"."personGroupId" = "asset_face"."personGroupId"
- and "person"."ownerId" = $5
+ and "person"."ownerId" = $4
) as obj
) as "person"
from
"asset_face"
where
- "asset_face"."assetId" in ($6)
- and "asset_face"."personGroupId" in ($7)
+ "asset_face"."assetId" in ($5)
+ and "asset_face"."personGroupId" in ($6)
and "asset_face"."deletedAt" is null
-- PersonRepository.getRandomFace
diff --git a/server/src/repositories/person.repository.ts b/server/src/repositories/person.repository.ts
index ba8844a8b1..9b9235b8b9 100644
--- a/server/src/repositories/person.repository.ts
+++ b/server/src/repositories/person.repository.ts
@@ -138,8 +138,7 @@ const withOtherPeopleFor = (userId: string, personGroupId: Expression<string>) =
.on('person_user.sharedWithId', '=', userId),
)
.select(['person_user.sharedById', 'person_user.role', 'other.name', 'other.birthDate'])
- .where('other.personGroupId', '=', personGroupId)
- .where((eb) => eb.or([eb('other.birthDate', 'is not', null), eb('other.name', '!=', '')])),
+ .where('other.personGroupId', '=', personGroupId),
).as('otherPeople');
const withPersonUsersFor = (userId: string, personGroupId: Expression<string>, direction: SharingDirection) => {