2023-11-30 10:10:30 -05:00
|
|
|
-- NOTE: This file is auto generated by ./sql-generator
|
|
|
|
|
|
|
|
|
|
-- PersonRepository.reassignFaces
|
2025-07-14 10:13:06 -04:00
|
|
|
update "asset_face"
|
2025-01-21 19:12:28 +01:00
|
|
|
set
|
2026-08-12 13:19:08 -04:00
|
|
|
"personGroupId" = $1
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
"asset_face"."personGroupId" = $2
|
2023-11-30 10:10:30 -05:00
|
|
|
|
2025-01-21 19:12:28 +01:00
|
|
|
-- PersonRepository.delete
|
|
|
|
|
delete from "person"
|
|
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
(
|
|
|
|
|
"person"."ownerId" = $1
|
|
|
|
|
and "person"."personGroupId" = $2
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
-- PersonRepository.deleteGroups
|
|
|
|
|
delete from "person_group"
|
|
|
|
|
where
|
|
|
|
|
"person_group"."id" in ($1)
|
|
|
|
|
|
|
|
|
|
-- PersonRepository.deleteEmptyGroups
|
|
|
|
|
delete from "person_group"
|
|
|
|
|
where
|
|
|
|
|
not exists (
|
|
|
|
|
select
|
|
|
|
|
"person"."personGroupId"
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
|
|
|
|
"person"."personGroupId" = "person_group"."id"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
-- PersonRepository.deleteOrphanedClusterGroups
|
|
|
|
|
delete from "cluster_group"
|
|
|
|
|
where
|
|
|
|
|
not exists (
|
|
|
|
|
select
|
|
|
|
|
"user"."id"
|
|
|
|
|
from
|
|
|
|
|
"user"
|
|
|
|
|
where
|
|
|
|
|
"user"."clusterGroupId" = "cluster_group"."id"
|
|
|
|
|
)
|
2023-11-30 10:10:30 -05:00
|
|
|
|
2025-07-18 10:57:29 -04:00
|
|
|
-- PersonRepository.getFileSamples
|
|
|
|
|
select
|
2026-08-12 13:19:08 -04:00
|
|
|
"ownerId",
|
|
|
|
|
"personGroupId",
|
2025-07-18 10:57:29 -04:00
|
|
|
"thumbnailPath"
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
|
|
|
|
"thumbnailPath" != ''
|
|
|
|
|
limit
|
|
|
|
|
3
|
|
|
|
|
|
2025-06-19 17:05:03 +01:00
|
|
|
-- PersonRepository.getAllForUser
|
|
|
|
|
select
|
|
|
|
|
"person".*
|
|
|
|
|
from
|
|
|
|
|
"person"
|
2026-08-12 13:19:08 -04:00
|
|
|
inner join "asset_face" on "asset_face"."personGroupId" = "person"."personGroupId"
|
2025-07-14 10:13:06 -04:00
|
|
|
inner join "asset" on "asset_face"."assetId" = "asset"."id"
|
2026-08-12 13:19:08 -04:00
|
|
|
and "asset"."ownerId" = "person"."ownerId"
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset"."visibility" = 'timeline'
|
|
|
|
|
and "asset"."deletedAt" is null
|
2025-06-19 17:05:03 +01:00
|
|
|
where
|
|
|
|
|
"person"."ownerId" = $1
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset_face"."deletedAt" is null
|
2026-01-09 17:59:52 -05:00
|
|
|
and "asset_face"."isVisible" is true
|
2025-06-19 17:05:03 +01:00
|
|
|
and "person"."isHidden" = $2
|
|
|
|
|
group by
|
2026-08-12 13:19:08 -04:00
|
|
|
"person"."ownerId",
|
|
|
|
|
"person"."personGroupId"
|
2025-06-19 17:05:03 +01:00
|
|
|
having
|
|
|
|
|
(
|
|
|
|
|
"person"."name" != $3
|
2026-06-02 09:05:55 -07:00
|
|
|
or count("asset_face"."assetId") >= COALESCE(
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
value -> 'people' ->> 'minimumFaces'
|
|
|
|
|
FROM
|
|
|
|
|
user_metadata
|
|
|
|
|
WHERE
|
|
|
|
|
"userId" = $4
|
|
|
|
|
AND key = 'preferences'
|
|
|
|
|
),
|
|
|
|
|
'3'
|
|
|
|
|
)::int
|
2025-06-19 17:05:03 +01:00
|
|
|
)
|
|
|
|
|
order by
|
|
|
|
|
"person"."isHidden" asc,
|
|
|
|
|
"person"."isFavorite" desc,
|
2025-06-20 13:34:04 +01:00
|
|
|
NULLIF(person.name, '') is null asc,
|
2025-07-14 10:13:06 -04:00
|
|
|
count("asset_face"."assetId") desc,
|
2025-06-20 13:34:04 +01:00
|
|
|
NULLIF(person.name, '') asc nulls last,
|
2025-06-19 17:05:03 +01:00
|
|
|
"person"."createdAt"
|
|
|
|
|
limit
|
|
|
|
|
$5
|
|
|
|
|
offset
|
|
|
|
|
$6
|
|
|
|
|
|
2023-11-30 10:10:30 -05:00
|
|
|
-- PersonRepository.getAllWithoutFaces
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
|
|
|
|
"person".*
|
|
|
|
|
from
|
|
|
|
|
"person"
|
2026-08-12 13:19:08 -04:00
|
|
|
left join "asset_face" on "asset_face"."personGroupId" = "person"."personGroupId"
|
2025-02-21 09:58:25 -06:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."deletedAt" is null
|
2026-01-09 17:59:52 -05:00
|
|
|
and "asset_face"."isVisible" is true
|
2025-01-21 19:12:28 +01:00
|
|
|
group by
|
2026-08-12 13:19:08 -04:00
|
|
|
"person"."ownerId",
|
|
|
|
|
"person"."personGroupId"
|
2025-01-21 19:12:28 +01:00
|
|
|
having
|
2025-07-14 10:13:06 -04:00
|
|
|
count("asset_face"."assetId") = $1
|
2023-11-30 10:10:30 -05:00
|
|
|
|
2023-12-05 16:43:15 +01:00
|
|
|
-- PersonRepository.getFaces
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face".*,
|
2025-01-21 19:12:28 +01:00
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"person".*
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
"person"."personGroupId" = "asset_face"."personGroupId"
|
2026-08-13 13:16:58 -04:00
|
|
|
and "person"."ownerId" = $1
|
2025-01-21 19:12:28 +01:00
|
|
|
) as obj
|
|
|
|
|
) as "person"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2026-08-13 13:16:58 -04:00
|
|
|
"asset_face"."assetId" = $2
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset_face"."deletedAt" is null
|
2026-08-13 13:16:58 -04:00
|
|
|
and "asset_face"."isVisible" = $3
|
2025-01-21 19:12:28 +01:00
|
|
|
order by
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."boundingBoxX1" asc
|
2023-12-05 16:43:15 +01:00
|
|
|
|
|
|
|
|
-- PersonRepository.getFaceById
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face".*,
|
2023-12-05 16:43:15 +01:00
|
|
|
(
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"person".*
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
"person"."personGroupId" = "asset_face"."personGroupId"
|
2026-08-13 13:16:58 -04:00
|
|
|
and "person"."ownerId" = $1
|
2025-01-21 19:12:28 +01:00
|
|
|
) as obj
|
|
|
|
|
) as "person"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2026-08-13 13:16:58 -04:00
|
|
|
"asset_face"."id" = $2
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset_face"."deletedAt" is null
|
2023-11-30 10:10:30 -05:00
|
|
|
|
2025-04-11 14:44:45 -04:00
|
|
|
-- PersonRepository.getFaceForFacialRecognitionJob
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."id",
|
2026-08-12 13:19:08 -04:00
|
|
|
"asset_face"."personGroupId",
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."sourceType",
|
2025-01-21 19:12:28 +01:00
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."ownerId",
|
|
|
|
|
"asset"."visibility",
|
2026-08-12 13:19:08 -04:00
|
|
|
"asset"."fileCreatedAt",
|
|
|
|
|
"user"."clusterGroupId"
|
2025-01-21 19:12:28 +01:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"
|
2026-08-12 13:19:08 -04:00
|
|
|
inner join "user" on "user"."id" = "asset"."ownerId"
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."id" = "asset_face"."assetId"
|
2025-01-21 19:12:28 +01:00
|
|
|
) as obj
|
2025-04-11 14:44:45 -04:00
|
|
|
) as "asset",
|
2023-12-05 16:43:15 +01:00
|
|
|
(
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
2025-04-11 14:44:45 -04:00
|
|
|
"face_search".*
|
2025-01-21 19:12:28 +01:00
|
|
|
from
|
2025-04-11 14:44:45 -04:00
|
|
|
"face_search"
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"face_search"."faceId" = "asset_face"."id"
|
2025-01-21 19:12:28 +01:00
|
|
|
) as obj
|
2025-04-11 14:44:45 -04:00
|
|
|
) as "faceSearch"
|
2025-01-21 19:12:28 +01:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."id" = $1
|
|
|
|
|
and "asset_face"."deletedAt" is null
|
2023-12-05 16:43:15 +01:00
|
|
|
|
2025-04-11 14:44:45 -04:00
|
|
|
-- PersonRepository.getDataForThumbnailGenerationJob
|
|
|
|
|
select
|
|
|
|
|
"person"."ownerId",
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."boundingBoxX1" as "x1",
|
|
|
|
|
"asset_face"."boundingBoxY1" as "y1",
|
|
|
|
|
"asset_face"."boundingBoxX2" as "x2",
|
|
|
|
|
"asset_face"."boundingBoxY2" as "y2",
|
|
|
|
|
"asset_face"."imageWidth" as "oldWidth",
|
|
|
|
|
"asset_face"."imageHeight" as "oldHeight",
|
|
|
|
|
"asset"."type",
|
|
|
|
|
"asset"."originalPath",
|
|
|
|
|
"asset_exif"."orientation" as "exifOrientation",
|
2025-05-14 23:23:34 -04:00
|
|
|
(
|
|
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_file"."path"
|
2025-05-14 23:23:34 -04:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_file"
|
2025-05-14 23:23:34 -04:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_file"."assetId" = "asset"."id"
|
|
|
|
|
and "asset_file"."type" = 'preview'
|
2026-04-01 07:19:38 -05:00
|
|
|
and "asset_file"."isEdited" = false
|
2025-05-14 23:23:34 -04:00
|
|
|
) as "previewPath"
|
2025-04-11 14:44:45 -04:00
|
|
|
from
|
|
|
|
|
"person"
|
2025-07-14 10:13:06 -04:00
|
|
|
inner join "asset_face" on "asset_face"."id" = "person"."faceAssetId"
|
|
|
|
|
inner join "asset" on "asset_face"."assetId" = "asset"."id"
|
|
|
|
|
left join "asset_exif" on "asset_exif"."assetId" = "asset"."id"
|
2025-04-11 14:44:45 -04:00
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
"person"."ownerId" = $1
|
|
|
|
|
and "person"."personGroupId" = $2
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset_face"."deletedAt" is null
|
2025-04-11 14:44:45 -04:00
|
|
|
|
2023-12-05 16:43:15 +01:00
|
|
|
-- PersonRepository.reassignFace
|
2025-07-14 10:13:06 -04:00
|
|
|
update "asset_face"
|
2025-01-21 19:12:28 +01:00
|
|
|
set
|
2026-08-12 13:19:08 -04:00
|
|
|
"personGroupId" = $1
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."id" = $2
|
2023-12-05 16:43:15 +01:00
|
|
|
|
2026-08-12 13:19:08 -04:00
|
|
|
-- PersonRepository.getByGroupId
|
|
|
|
|
select
|
|
|
|
|
"person".*
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
|
|
|
|
"person"."personGroupId" = $1
|
|
|
|
|
and "person"."ownerId" = $2
|
|
|
|
|
|
2023-11-30 10:10:30 -05:00
|
|
|
-- PersonRepository.getByName
|
2026-04-09 01:56:07 +01:00
|
|
|
with
|
|
|
|
|
"similarity_threshold" as (
|
|
|
|
|
select
|
|
|
|
|
set_config('pg_trgm.word_similarity_threshold', '0.5', true) as "thresh"
|
|
|
|
|
)
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
|
|
|
|
"person".*
|
|
|
|
|
from
|
2026-04-09 01:56:07 +01:00
|
|
|
"similarity_threshold",
|
2025-01-21 19:12:28 +01:00
|
|
|
"person"
|
|
|
|
|
where
|
2026-04-01 19:01:54 +05:30
|
|
|
"person"."ownerId" = $1
|
2026-04-09 01:56:07 +01:00
|
|
|
and f_unaccent ("person"."name") %> f_unaccent ($2)
|
2026-04-01 19:01:54 +05:30
|
|
|
order by
|
|
|
|
|
f_unaccent ("person"."name") <->>> f_unaccent ($3)
|
2025-01-21 19:12:28 +01:00
|
|
|
limit
|
|
|
|
|
$4
|
2023-11-30 10:10:30 -05:00
|
|
|
|
2024-09-05 00:23:58 +02:00
|
|
|
-- PersonRepository.getDistinctNames
|
2025-01-21 19:12:28 +01:00
|
|
|
select distinct
|
2026-08-12 13:19:08 -04:00
|
|
|
on (lower("person"."name")) "person"."personGroupId",
|
2025-01-21 19:12:28 +01:00
|
|
|
"person"."name"
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
|
|
|
|
(
|
|
|
|
|
"person"."ownerId" = $1
|
|
|
|
|
and "person"."name" != $2
|
|
|
|
|
)
|
2024-09-05 00:23:58 +02:00
|
|
|
|
2023-11-30 10:10:30 -05:00
|
|
|
-- PersonRepository.getStatistics
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
count(distinct ("asset"."id")) as "count"
|
2025-01-21 19:12:28 +01:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"
|
|
|
|
|
left join "asset" on "asset"."id" = "asset_face"."assetId"
|
|
|
|
|
and "asset"."visibility" = 'timeline'
|
|
|
|
|
and "asset"."deletedAt" is null
|
2025-02-21 09:58:25 -06:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."deletedAt" is null
|
2026-01-09 17:59:52 -05:00
|
|
|
and "asset_face"."isVisible" is true
|
2026-08-12 13:19:08 -04:00
|
|
|
and "asset_face"."personGroupId" = $1
|
2023-11-30 10:10:30 -05:00
|
|
|
|
2024-01-28 01:54:31 +01:00
|
|
|
-- PersonRepository.getNumberOfPeople
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
2025-06-02 10:33:08 -04:00
|
|
|
coalesce(count(*), 0) as "total",
|
|
|
|
|
coalesce(
|
|
|
|
|
count(*) filter (
|
|
|
|
|
where
|
|
|
|
|
"isHidden" = $1
|
|
|
|
|
),
|
|
|
|
|
0
|
2025-01-21 19:12:28 +01:00
|
|
|
) as "hidden"
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
2025-06-02 10:33:08 -04:00
|
|
|
exists (
|
|
|
|
|
select
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"
|
2025-06-02 10:33:08 -04:00
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
"asset_face"."personGroupId" = "person"."personGroupId"
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset_face"."deletedAt" is null
|
2026-01-09 17:59:52 -05:00
|
|
|
and "asset_face"."isVisible" = $2
|
2025-06-02 10:33:08 -04:00
|
|
|
and exists (
|
|
|
|
|
select
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"
|
2025-06-02 10:33:08 -04:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset"."id" = "asset_face"."assetId"
|
|
|
|
|
and "asset"."visibility" = 'timeline'
|
|
|
|
|
and "asset"."deletedAt" is null
|
2025-06-02 10:33:08 -04:00
|
|
|
)
|
|
|
|
|
)
|
2026-01-09 17:59:52 -05:00
|
|
|
and "person"."ownerId" = $3
|
2025-01-21 19:12:28 +01:00
|
|
|
|
2026-08-12 13:19:08 -04:00
|
|
|
-- PersonRepository.createGroup
|
|
|
|
|
insert into
|
|
|
|
|
"person_group" ("clusterGroupId")
|
|
|
|
|
select
|
|
|
|
|
"user"."clusterGroupId"
|
|
|
|
|
from
|
|
|
|
|
"user"
|
|
|
|
|
where
|
|
|
|
|
"user"."id" = $1
|
|
|
|
|
returning
|
|
|
|
|
*
|
|
|
|
|
|
|
|
|
|
-- PersonRepository.reassignCluster
|
|
|
|
|
begin
|
|
|
|
|
update "person_group"
|
|
|
|
|
set
|
|
|
|
|
"clusterGroupId" = $1
|
|
|
|
|
where
|
|
|
|
|
"person_group"."id" in (
|
|
|
|
|
select
|
|
|
|
|
"person"."personGroupId"
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
|
|
|
|
"person"."ownerId" = $2
|
|
|
|
|
)
|
|
|
|
|
and not exists (
|
|
|
|
|
select
|
|
|
|
|
"person"."personGroupId"
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
|
|
|
|
"person"."personGroupId" = "person_group"."id"
|
|
|
|
|
and "person"."ownerId" != $3
|
|
|
|
|
)
|
|
|
|
|
with
|
|
|
|
|
"shared" as (
|
|
|
|
|
select distinct
|
|
|
|
|
"person"."personGroupId" as "oldId"
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
|
|
|
|
"person"."ownerId" = $1
|
|
|
|
|
and exists (
|
|
|
|
|
select
|
|
|
|
|
"other"."personGroupId"
|
|
|
|
|
from
|
|
|
|
|
"person" as "other"
|
|
|
|
|
where
|
|
|
|
|
"other"."personGroupId" = "person"."personGroupId"
|
|
|
|
|
and "other"."ownerId" != $2
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
"mapping" as materialized (
|
|
|
|
|
select
|
|
|
|
|
"shared"."oldId",
|
|
|
|
|
uuid_generate_v4 () as "newId"
|
|
|
|
|
from
|
|
|
|
|
"shared"
|
|
|
|
|
),
|
|
|
|
|
"created" as (
|
|
|
|
|
insert into
|
|
|
|
|
"person_group" ("id", "clusterGroupId")
|
|
|
|
|
select
|
|
|
|
|
"mapping"."newId",
|
|
|
|
|
$3 as "clusterGroupId"
|
|
|
|
|
from
|
|
|
|
|
"mapping"
|
|
|
|
|
)
|
|
|
|
|
select
|
|
|
|
|
"mapping"."oldId",
|
|
|
|
|
"mapping"."newId"
|
|
|
|
|
from
|
|
|
|
|
"mapping"
|
|
|
|
|
commit
|
|
|
|
|
|
|
|
|
|
-- PersonRepository.createGroups
|
|
|
|
|
insert into
|
|
|
|
|
"person_group" (
|
|
|
|
|
"0",
|
|
|
|
|
"1",
|
|
|
|
|
"2",
|
|
|
|
|
"3",
|
|
|
|
|
"4",
|
|
|
|
|
"5",
|
|
|
|
|
"6",
|
|
|
|
|
"7",
|
|
|
|
|
"8",
|
|
|
|
|
"9",
|
|
|
|
|
"10",
|
|
|
|
|
"11",
|
|
|
|
|
"12",
|
|
|
|
|
"13",
|
|
|
|
|
"14",
|
|
|
|
|
"15",
|
|
|
|
|
"16",
|
|
|
|
|
"17",
|
|
|
|
|
"18",
|
|
|
|
|
"19",
|
|
|
|
|
"20",
|
|
|
|
|
"21",
|
|
|
|
|
"22",
|
|
|
|
|
"23",
|
|
|
|
|
"24",
|
|
|
|
|
"25",
|
|
|
|
|
"26",
|
|
|
|
|
"27",
|
|
|
|
|
"28",
|
|
|
|
|
"29",
|
|
|
|
|
"30",
|
|
|
|
|
"31",
|
|
|
|
|
"32",
|
|
|
|
|
"33",
|
|
|
|
|
"34",
|
|
|
|
|
"35"
|
|
|
|
|
)
|
|
|
|
|
values
|
|
|
|
|
(
|
|
|
|
|
$1,
|
|
|
|
|
$2,
|
|
|
|
|
$3,
|
|
|
|
|
$4,
|
|
|
|
|
$5,
|
|
|
|
|
$6,
|
|
|
|
|
$7,
|
|
|
|
|
$8,
|
|
|
|
|
$9,
|
|
|
|
|
$10,
|
|
|
|
|
$11,
|
|
|
|
|
$12,
|
|
|
|
|
$13,
|
|
|
|
|
$14,
|
|
|
|
|
$15,
|
|
|
|
|
$16,
|
|
|
|
|
$17,
|
|
|
|
|
$18,
|
|
|
|
|
$19,
|
|
|
|
|
$20,
|
|
|
|
|
$21,
|
|
|
|
|
$22,
|
|
|
|
|
$23,
|
|
|
|
|
$24,
|
|
|
|
|
$25,
|
|
|
|
|
$26,
|
|
|
|
|
$27,
|
|
|
|
|
$28,
|
|
|
|
|
$29,
|
|
|
|
|
$30,
|
|
|
|
|
$31,
|
|
|
|
|
$32,
|
|
|
|
|
$33,
|
|
|
|
|
$34,
|
|
|
|
|
$35,
|
|
|
|
|
$36
|
|
|
|
|
)
|
|
|
|
|
returning
|
|
|
|
|
*
|
|
|
|
|
|
2025-05-20 09:36:43 -04:00
|
|
|
-- PersonRepository.refreshFaces
|
|
|
|
|
with
|
|
|
|
|
"added_embeddings" as (
|
|
|
|
|
insert into
|
|
|
|
|
"face_search" ("faceId", "embedding")
|
|
|
|
|
values
|
|
|
|
|
($1, $2)
|
|
|
|
|
)
|
|
|
|
|
select
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
1
|
|
|
|
|
) as "dummy"
|
|
|
|
|
|
2023-11-30 10:10:30 -05:00
|
|
|
-- PersonRepository.getFacesByIds
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face".*,
|
2025-01-21 19:12:28 +01:00
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
to_json(obj)
|
|
|
|
|
from
|
|
|
|
|
(
|
|
|
|
|
select
|
|
|
|
|
"person".*
|
|
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
"person"."personGroupId" = "asset_face"."personGroupId"
|
2026-08-13 13:16:58 -04:00
|
|
|
and "person"."ownerId" = $1
|
2025-01-21 19:12:28 +01:00
|
|
|
) as obj
|
|
|
|
|
) as "person"
|
|
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2026-08-13 13:16:58 -04:00
|
|
|
"asset_face"."assetId" in ($2)
|
|
|
|
|
and "asset_face"."personGroupId" in ($3)
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset_face"."deletedAt" is null
|
2023-11-30 10:10:30 -05:00
|
|
|
|
|
|
|
|
-- PersonRepository.getRandomFace
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face".*
|
2025-01-21 19:12:28 +01:00
|
|
|
from
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"
|
2025-01-21 19:12:28 +01:00
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
"asset_face"."personGroupId" = $1
|
2025-07-14 10:13:06 -04:00
|
|
|
and "asset_face"."deletedAt" is null
|
2026-01-09 17:59:52 -05:00
|
|
|
and "asset_face"."isVisible" is true
|
2024-07-14 18:53:42 -04:00
|
|
|
|
|
|
|
|
-- PersonRepository.getLatestFaceDate
|
2025-01-21 19:12:28 +01:00
|
|
|
select
|
|
|
|
|
max("asset_job_status"."facesRecognizedAt")::text as "latestDate"
|
|
|
|
|
from
|
|
|
|
|
"asset_job_status"
|
2025-02-21 09:58:25 -06:00
|
|
|
|
|
|
|
|
-- PersonRepository.deleteAssetFace
|
2025-07-14 10:13:06 -04:00
|
|
|
delete from "asset_face"
|
2025-02-21 09:58:25 -06:00
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."id" = $1
|
2025-02-21 09:58:25 -06:00
|
|
|
|
|
|
|
|
-- PersonRepository.softDeleteAssetFaces
|
2025-07-14 10:13:06 -04:00
|
|
|
update "asset_face"
|
2025-02-21 09:58:25 -06:00
|
|
|
set
|
|
|
|
|
"deletedAt" = $1
|
|
|
|
|
where
|
2025-07-14 10:13:06 -04:00
|
|
|
"asset_face"."id" = $2
|
2025-06-25 11:12:36 -04:00
|
|
|
|
|
|
|
|
-- PersonRepository.getForPeopleDelete
|
|
|
|
|
select
|
2026-08-12 13:19:08 -04:00
|
|
|
"person"."ownerId",
|
|
|
|
|
"person"."personGroupId",
|
|
|
|
|
"person"."thumbnailPath"
|
2025-06-25 11:12:36 -04:00
|
|
|
from
|
|
|
|
|
"person"
|
|
|
|
|
where
|
2026-08-12 13:19:08 -04:00
|
|
|
"person"."personGroupId" in ($1)
|
2026-02-19 14:51:18 +01:00
|
|
|
|
|
|
|
|
-- PersonRepository.getForFeatureFaceUpdate
|
|
|
|
|
select
|
|
|
|
|
"asset_face"."id"
|
|
|
|
|
from
|
|
|
|
|
"asset_face"
|
|
|
|
|
inner join "asset" on "asset"."id" = "asset_face"."assetId"
|
|
|
|
|
and "asset"."isOffline" = $1
|
|
|
|
|
where
|
|
|
|
|
"asset_face"."assetId" = $2
|
2026-08-12 13:19:08 -04:00
|
|
|
and "asset_face"."personGroupId" = $3
|