fix: include unamed people in otherPeople (#32239)
fix: include unamed people in otherPeople (#32237) (cherry picked from commit 9971dade1b2db76a5a79d287eb2d725152cb0323) Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
co-authored by
Jason Rasmussen
parent
f7dd3ccdc6
commit
3b53f1b4bb
@@ -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,94 +630,6 @@ select
|
||||
and "user"."deletedAt" is null
|
||||
where
|
||||
"person_user"."personGroupId" = "person_group"."id"
|
||||
and "person_user"."sharedWithId" = $4
|
||||
order by
|
||||
"user"."name"
|
||||
) as agg
|
||||
) as "sharedBy",
|
||||
(
|
||||
select
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"avatarColor",
|
||||
"profileImagePath",
|
||||
"profileChangedAt",
|
||||
"person_user"."role"
|
||||
from
|
||||
"person_user"
|
||||
inner join "user" on "user"."id" = "person_user"."sharedWithId"
|
||||
and "user"."deletedAt" is null
|
||||
where
|
||||
"person_user"."personGroupId" = "person_group"."id"
|
||||
and "person_user"."sharedById" = $5
|
||||
order by
|
||||
"user"."name"
|
||||
) as agg
|
||||
) as "sharedWith"
|
||||
from
|
||||
"person_group"
|
||||
where
|
||||
"person_group"."id" = $6
|
||||
and exists (
|
||||
select
|
||||
"person"."ownerId"
|
||||
from
|
||||
"person"
|
||||
where
|
||||
"person"."personGroupId" = "person_group"."id"
|
||||
and "person"."ownerId" = $7
|
||||
)
|
||||
|
||||
-- PersonRepository.getByGroupId
|
||||
select
|
||||
"person".*,
|
||||
(
|
||||
select
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
(
|
||||
select
|
||||
"person_user"."sharedById",
|
||||
"person_user"."role",
|
||||
"other"."name",
|
||||
"other"."birthDate"
|
||||
from
|
||||
"person" as "other"
|
||||
inner join "person_user" on "person_user"."personGroupId" = "other"."personGroupId"
|
||||
and "person_user"."sharedById" = "other"."ownerId"
|
||||
and "person_user"."sharedWithId" = $1
|
||||
where
|
||||
"other"."personGroupId" = "person"."personGroupId"
|
||||
and (
|
||||
"other"."birthDate" is not null
|
||||
or "other"."name" != $2
|
||||
)
|
||||
) as agg
|
||||
) as "otherPeople",
|
||||
(
|
||||
select
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"avatarColor",
|
||||
"profileImagePath",
|
||||
"profileChangedAt",
|
||||
"person_user"."role"
|
||||
from
|
||||
"person_user"
|
||||
inner join "user" on "user"."id" = "person_user"."sharedById"
|
||||
and "user"."deletedAt" is null
|
||||
where
|
||||
"person_user"."personGroupId" = "person"."personGroupId"
|
||||
and "person_user"."sharedWithId" = $3
|
||||
order by
|
||||
"user"."name"
|
||||
@@ -757,17 +653,101 @@ select
|
||||
inner join "user" on "user"."id" = "person_user"."sharedWithId"
|
||||
and "user"."deletedAt" is null
|
||||
where
|
||||
"person_user"."personGroupId" = "person"."personGroupId"
|
||||
"person_user"."personGroupId" = "person_group"."id"
|
||||
and "person_user"."sharedById" = $4
|
||||
order by
|
||||
"user"."name"
|
||||
) as agg
|
||||
) as "sharedWith"
|
||||
from
|
||||
"person_group"
|
||||
where
|
||||
"person_group"."id" = $5
|
||||
and exists (
|
||||
select
|
||||
"person"."ownerId"
|
||||
from
|
||||
"person"
|
||||
where
|
||||
"person"."personGroupId" = "person_group"."id"
|
||||
and "person"."ownerId" = $6
|
||||
)
|
||||
|
||||
-- PersonRepository.getByGroupId
|
||||
select
|
||||
"person".*,
|
||||
(
|
||||
select
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
(
|
||||
select
|
||||
"person_user"."sharedById",
|
||||
"person_user"."role",
|
||||
"other"."name",
|
||||
"other"."birthDate"
|
||||
from
|
||||
"person" as "other"
|
||||
inner join "person_user" on "person_user"."personGroupId" = "other"."personGroupId"
|
||||
and "person_user"."sharedById" = "other"."ownerId"
|
||||
and "person_user"."sharedWithId" = $1
|
||||
where
|
||||
"other"."personGroupId" = "person"."personGroupId"
|
||||
) as agg
|
||||
) as "otherPeople",
|
||||
(
|
||||
select
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"avatarColor",
|
||||
"profileImagePath",
|
||||
"profileChangedAt",
|
||||
"person_user"."role"
|
||||
from
|
||||
"person_user"
|
||||
inner join "user" on "user"."id" = "person_user"."sharedById"
|
||||
and "user"."deletedAt" is null
|
||||
where
|
||||
"person_user"."personGroupId" = "person"."personGroupId"
|
||||
and "person_user"."sharedWithId" = $2
|
||||
order by
|
||||
"user"."name"
|
||||
) as agg
|
||||
) as "sharedBy",
|
||||
(
|
||||
select
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
(
|
||||
select
|
||||
"id",
|
||||
"name",
|
||||
"email",
|
||||
"avatarColor",
|
||||
"profileImagePath",
|
||||
"profileChangedAt",
|
||||
"person_user"."role"
|
||||
from
|
||||
"person_user"
|
||||
inner join "user" on "user"."id" = "person_user"."sharedWithId"
|
||||
and "user"."deletedAt" is null
|
||||
where
|
||||
"person_user"."personGroupId" = "person"."personGroupId"
|
||||
and "person_user"."sharedById" = $3
|
||||
order by
|
||||
"user"."name"
|
||||
) as agg
|
||||
) as "sharedWith"
|
||||
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
|
||||
|
||||
@@ -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) => {
|
||||
|
||||
Reference in New Issue
Block a user