immich/server/src/queries/person.repository.sql

580 lines
10 KiB
MySQL
Raw Normal View History

-- NOTE: This file is auto generated by ./sql-generator
-- PersonRepository.reassignFaces
2025-07-14 10:13:06 -04:00
update "asset_face"
set
2026-08-12 13:19:08 -04:00
"personGroupId" = $1
where
2026-08-12 13:19:08 -04:00
"asset_face"."personGroupId" = $2
-- 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"
)
-- PersonRepository.getFileSamples
select
2026-08-12 13:19:08 -04:00
"ownerId",
"personGroupId",
"thumbnailPath"
from
"person"
where
"thumbnailPath" != ''
limit
3
-- 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
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
and "person"."isHidden" = $2
group by
2026-08-12 13:19:08 -04:00
"person"."ownerId",
"person"."personGroupId"
having
(
"person"."name" != $3
or count("asset_face"."assetId") >= COALESCE(
(
SELECT
value -> 'people' ->> 'minimumFaces'
FROM
user_metadata
WHERE
"userId" = $4
AND key = 'preferences'
),
'3'
)::int
)
order by
"person"."isHidden" asc,
"person"."isFavorite" desc,
NULLIF(person.name, '') is null asc,
2025-07-14 10:13:06 -04:00
count("asset_face"."assetId") desc,
NULLIF(person.name, '') asc nulls last,
"person"."createdAt"
limit
$5
offset
$6
-- PersonRepository.getAllWithoutFaces
select
"person".*
from
"person"
2026-08-12 13:19:08 -04:00
left join "asset_face" on "asset_face"."personGroupId" = "person"."personGroupId"
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
group by
2026-08-12 13:19:08 -04:00
"person"."ownerId",
"person"."personGroupId"
having
2025-07-14 10:13:06 -04:00
count("asset_face"."assetId") = $1
feat(web): re-assign person faces (2) (#4949) * feat: unassign person faces * multiple improvements * chore: regenerate api * feat: improve face interactions in photos * fix: tests * fix: tests * optimize * fix: wrong assignment on complex-multiple re-assignments * fix: thumbnails with large photos * fix: complex reassign * fix: don't send people with faces * fix: person thumbnail generation * chore: regenerate api * add tess * feat: face box even when zoomed * fix: change feature photo * feat: make the blue icon hoverable * chore: regenerate api * feat: use websocket * fix: loading spinner when clicking on the done button * fix: use the svelte way * fix: tests * simplify * fix: unused vars * fix: remove unused code * fix: add migration * chore: regenerate api * ci: add unit tests * chore: regenerate api * feat: if a new person is created for a face and the server takes more than 15 seconds to generate the person thumbnail, don't wait for it * reorganize * chore: regenerate api * feat: global edit * pr feedback * pr feedback * simplify * revert test * fix: face generation * fix: tests * fix: face generation * fix merge * feat: search names in unmerge face selector modal * fix: merge face selector * simplify feature photo generation * fix: change endpoint * pr feedback * chore: fix merge * chore: fix merge * fix: tests * fix: edit & hide buttons * fix: tests * feat: show if person is hidden * feat: rename face to person * feat: split in new panel * copy-paste-error * pr feedback * fix: feature photo * do not leak faces * fix: unmerge modal * fix: merge modal event * feat(server): remove duplicates * fix: title for image thumbnails * fix: disable side panel when there's no face until next PR --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-12-05 16:43:15 +01:00
-- PersonRepository.getFaces
select
2025-07-14 10:13:06 -04:00
"asset_face".*,
(
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
) as obj
) as "person"
from
2025-07-14 10:13:06 -04:00
"asset_face"
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
order by
2025-07-14 10:13:06 -04:00
"asset_face"."boundingBoxX1" asc
feat(web): re-assign person faces (2) (#4949) * feat: unassign person faces * multiple improvements * chore: regenerate api * feat: improve face interactions in photos * fix: tests * fix: tests * optimize * fix: wrong assignment on complex-multiple re-assignments * fix: thumbnails with large photos * fix: complex reassign * fix: don't send people with faces * fix: person thumbnail generation * chore: regenerate api * add tess * feat: face box even when zoomed * fix: change feature photo * feat: make the blue icon hoverable * chore: regenerate api * feat: use websocket * fix: loading spinner when clicking on the done button * fix: use the svelte way * fix: tests * simplify * fix: unused vars * fix: remove unused code * fix: add migration * chore: regenerate api * ci: add unit tests * chore: regenerate api * feat: if a new person is created for a face and the server takes more than 15 seconds to generate the person thumbnail, don't wait for it * reorganize * chore: regenerate api * feat: global edit * pr feedback * pr feedback * simplify * revert test * fix: face generation * fix: tests * fix: face generation * fix merge * feat: search names in unmerge face selector modal * fix: merge face selector * simplify feature photo generation * fix: change endpoint * pr feedback * chore: fix merge * chore: fix merge * fix: tests * fix: edit & hide buttons * fix: tests * feat: show if person is hidden * feat: rename face to person * feat: split in new panel * copy-paste-error * pr feedback * fix: feature photo * do not leak faces * fix: unmerge modal * fix: merge modal event * feat(server): remove duplicates * fix: title for image thumbnails * fix: disable side panel when there's no face until next PR --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-12-05 16:43:15 +01:00
-- PersonRepository.getFaceById
select
2025-07-14 10:13:06 -04:00
"asset_face".*,
feat(web): re-assign person faces (2) (#4949) * feat: unassign person faces * multiple improvements * chore: regenerate api * feat: improve face interactions in photos * fix: tests * fix: tests * optimize * fix: wrong assignment on complex-multiple re-assignments * fix: thumbnails with large photos * fix: complex reassign * fix: don't send people with faces * fix: person thumbnail generation * chore: regenerate api * add tess * feat: face box even when zoomed * fix: change feature photo * feat: make the blue icon hoverable * chore: regenerate api * feat: use websocket * fix: loading spinner when clicking on the done button * fix: use the svelte way * fix: tests * simplify * fix: unused vars * fix: remove unused code * fix: add migration * chore: regenerate api * ci: add unit tests * chore: regenerate api * feat: if a new person is created for a face and the server takes more than 15 seconds to generate the person thumbnail, don't wait for it * reorganize * chore: regenerate api * feat: global edit * pr feedback * pr feedback * simplify * revert test * fix: face generation * fix: tests * fix: face generation * fix merge * feat: search names in unmerge face selector modal * fix: merge face selector * simplify feature photo generation * fix: change endpoint * pr feedback * chore: fix merge * chore: fix merge * fix: tests * fix: edit & hide buttons * fix: tests * feat: show if person is hidden * feat: rename face to person * feat: split in new panel * copy-paste-error * pr feedback * fix: feature photo * do not leak faces * fix: unmerge modal * fix: merge modal event * feat(server): remove duplicates * fix: title for image thumbnails * fix: disable side panel when there's no face until next PR --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-12-05 16:43:15 +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
) as obj
) as "person"
from
2025-07-14 10:13:06 -04:00
"asset_face"
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
-- PersonRepository.getFaceForFacialRecognitionJob
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",
(
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"
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"
where
2025-07-14 10:13:06 -04:00
"asset"."id" = "asset_face"."assetId"
) as obj
) as "asset",
feat(web): re-assign person faces (2) (#4949) * feat: unassign person faces * multiple improvements * chore: regenerate api * feat: improve face interactions in photos * fix: tests * fix: tests * optimize * fix: wrong assignment on complex-multiple re-assignments * fix: thumbnails with large photos * fix: complex reassign * fix: don't send people with faces * fix: person thumbnail generation * chore: regenerate api * add tess * feat: face box even when zoomed * fix: change feature photo * feat: make the blue icon hoverable * chore: regenerate api * feat: use websocket * fix: loading spinner when clicking on the done button * fix: use the svelte way * fix: tests * simplify * fix: unused vars * fix: remove unused code * fix: add migration * chore: regenerate api * ci: add unit tests * chore: regenerate api * feat: if a new person is created for a face and the server takes more than 15 seconds to generate the person thumbnail, don't wait for it * reorganize * chore: regenerate api * feat: global edit * pr feedback * pr feedback * simplify * revert test * fix: face generation * fix: tests * fix: face generation * fix merge * feat: search names in unmerge face selector modal * fix: merge face selector * simplify feature photo generation * fix: change endpoint * pr feedback * chore: fix merge * chore: fix merge * fix: tests * fix: edit & hide buttons * fix: tests * feat: show if person is hidden * feat: rename face to person * feat: split in new panel * copy-paste-error * pr feedback * fix: feature photo * do not leak faces * fix: unmerge modal * fix: merge modal event * feat(server): remove duplicates * fix: title for image thumbnails * fix: disable side panel when there's no face until next PR --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-12-05 16:43:15 +01:00
(
select
to_json(obj)
from
(
select
"face_search".*
from
"face_search"
where
2025-07-14 10:13:06 -04:00
"face_search"."faceId" = "asset_face"."id"
) as obj
) as "faceSearch"
from
2025-07-14 10:13:06 -04:00
"asset_face"
where
2025-07-14 10:13:06 -04:00
"asset_face"."id" = $1
and "asset_face"."deletedAt" is null
feat(web): re-assign person faces (2) (#4949) * feat: unassign person faces * multiple improvements * chore: regenerate api * feat: improve face interactions in photos * fix: tests * fix: tests * optimize * fix: wrong assignment on complex-multiple re-assignments * fix: thumbnails with large photos * fix: complex reassign * fix: don't send people with faces * fix: person thumbnail generation * chore: regenerate api * add tess * feat: face box even when zoomed * fix: change feature photo * feat: make the blue icon hoverable * chore: regenerate api * feat: use websocket * fix: loading spinner when clicking on the done button * fix: use the svelte way * fix: tests * simplify * fix: unused vars * fix: remove unused code * fix: add migration * chore: regenerate api * ci: add unit tests * chore: regenerate api * feat: if a new person is created for a face and the server takes more than 15 seconds to generate the person thumbnail, don't wait for it * reorganize * chore: regenerate api * feat: global edit * pr feedback * pr feedback * simplify * revert test * fix: face generation * fix: tests * fix: face generation * fix merge * feat: search names in unmerge face selector modal * fix: merge face selector * simplify feature photo generation * fix: change endpoint * pr feedback * chore: fix merge * chore: fix merge * fix: tests * fix: edit & hide buttons * fix: tests * feat: show if person is hidden * feat: rename face to person * feat: split in new panel * copy-paste-error * pr feedback * fix: feature photo * do not leak faces * fix: unmerge modal * fix: merge modal event * feat(server): remove duplicates * fix: title for image thumbnails * fix: disable side panel when there's no face until next PR --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-12-05 16:43:15 +01: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",
(
select
2025-07-14 10:13:06 -04:00
"asset_file"."path"
from
2025-07-14 10:13:06 -04:00
"asset_file"
where
2025-07-14 10:13:06 -04:00
"asset_file"."assetId" = "asset"."id"
and "asset_file"."type" = 'preview'
and "asset_file"."isEdited" = false
) as "previewPath"
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"
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
feat(web): re-assign person faces (2) (#4949) * feat: unassign person faces * multiple improvements * chore: regenerate api * feat: improve face interactions in photos * fix: tests * fix: tests * optimize * fix: wrong assignment on complex-multiple re-assignments * fix: thumbnails with large photos * fix: complex reassign * fix: don't send people with faces * fix: person thumbnail generation * chore: regenerate api * add tess * feat: face box even when zoomed * fix: change feature photo * feat: make the blue icon hoverable * chore: regenerate api * feat: use websocket * fix: loading spinner when clicking on the done button * fix: use the svelte way * fix: tests * simplify * fix: unused vars * fix: remove unused code * fix: add migration * chore: regenerate api * ci: add unit tests * chore: regenerate api * feat: if a new person is created for a face and the server takes more than 15 seconds to generate the person thumbnail, don't wait for it * reorganize * chore: regenerate api * feat: global edit * pr feedback * pr feedback * simplify * revert test * fix: face generation * fix: tests * fix: face generation * fix merge * feat: search names in unmerge face selector modal * fix: merge face selector * simplify feature photo generation * fix: change endpoint * pr feedback * chore: fix merge * chore: fix merge * fix: tests * fix: edit & hide buttons * fix: tests * feat: show if person is hidden * feat: rename face to person * feat: split in new panel * copy-paste-error * pr feedback * fix: feature photo * do not leak faces * fix: unmerge modal * fix: merge modal event * feat(server): remove duplicates * fix: title for image thumbnails * fix: disable side panel when there's no face until next PR --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
2023-12-05 16:43:15 +01:00
-- PersonRepository.reassignFace
2025-07-14 10:13:06 -04:00
update "asset_face"
set
2026-08-12 13:19:08 -04:00
"personGroupId" = $1
where
2025-07-14 10:13:06 -04:00
"asset_face"."id" = $2
feat(web): re-assign person faces (2) (#4949) * feat: unassign person faces * multiple improvements * chore: regenerate api * feat: improve face interactions in photos * fix: tests * fix: tests * optimize * fix: wrong assignment on complex-multiple re-assignments * fix: thumbnails with large photos * fix: complex reassign * fix: don't send people with faces * fix: person thumbnail generation * chore: regenerate api * add tess * feat: face box even when zoomed * fix: change feature photo * feat: make the blue icon hoverable * chore: regenerate api * feat: use websocket * fix: loading spinner when clicking on the done button * fix: use the svelte way * fix: tests * simplify * fix: unused vars * fix: remove unused code * fix: add migration * chore: regenerate api * ci: add unit tests * chore: regenerate api * feat: if a new person is created for a face and the server takes more than 15 seconds to generate the person thumbnail, don't wait for it * reorganize * chore: regenerate api * feat: global edit * pr feedback * pr feedback * simplify * revert test * fix: face generation * fix: tests * fix: face generation * fix merge * feat: search names in unmerge face selector modal * fix: merge face selector * simplify feature photo generation * fix: change endpoint * pr feedback * chore: fix merge * chore: fix merge * fix: tests * fix: edit & hide buttons * fix: tests * feat: show if person is hidden * feat: rename face to person * feat: split in new panel * copy-paste-error * pr feedback * fix: feature photo * do not leak faces * fix: unmerge modal * fix: merge modal event * feat(server): remove duplicates * fix: title for image thumbnails * fix: disable side panel when there's no face until next PR --------- Co-authored-by: Alex Tran <alex.tran1502@gmail.com>
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
-- PersonRepository.getByName
with
"similarity_threshold" as (
select
set_config('pg_trgm.word_similarity_threshold', '0.5', true) as "thresh"
)
select
"person".*
from
"similarity_threshold",
"person"
where
"person"."ownerId" = $1
and f_unaccent ("person"."name") %> f_unaccent ($2)
order by
f_unaccent ("person"."name") <->>> f_unaccent ($3)
limit
$4
feat(server): Import face regions from metadata (#6455) * feat: faces-from-metadata - Import face regions from metadata Implements immich-app#1692. - OpenAPI spec changes to accomodate metadata face import configs. New settings to enable the feature. - Updates admin UI compoments - ML faces detection/recognition & Exif/Metadata faces compatibility Signed-off-by: BugFest <bugfest.dev@pm.me> * chore(web): remove unused file confirm-enable-import-faces * chore(web): format metadata-settings * fix(server): faces-from-metadata tests and format * fix(server): code refinements, nullable face asset sourceType * fix(server): Add RegionInfo to ImmichTags interface * fix(server): deleteAllFaces sourceType param can be undefined * fix(server): exiftool-vendored 27.0.0 moves readArgs into ExifToolOptions * fix(server): rename isImportFacesFromMetadataEnabled to isFaceImportEnabled * fix(server): simplify sourceType conditional * fix(server): small fixes * fix(server): handling sourceType * fix(server): sourceType enum * fix(server): refactor metadata applyTaggedFaces * fix(server): create/update signature changes * fix(server): reduce computational cost of Person.getManyByName * fix(server): use faceList instead of faceSet * fix(server): Skip regions without Name defined * fix(mobile): Update open-api (face assets feature changes) * fix(server): Face-Person reconciliation with map/index * fix(server): tags.RegionInfo.AppliedToDimensions must be defined to process face-region * fix(server): fix shared-link.service.ts format * fix(mobile): Update open-api after branch update * simplify * fix(server): minor fixes * fix(server): person create/update methods type enforcement * fix(server): style fixes * fix(server): remove unused metadata code * fix(server): metadata faces unit tests * fix(server): top level config metadata category * fix(server): rename upsertFaces to replaceFaces * fix(server): remove sourceType when unnecessary * fix(server): sourceType as ENUM * fix(server): format fixes * fix(server): fix tests after sourceType ENUM change * fix(server): remove unnecessary JobItem cast * fix(server): fix asset enum imports * fix(open-api): add metadata config * fix(mobile): update open-api after metadata open-api spec changes * fix(web): update web/api metadata config * fix(server): remove duplicated sourceType def * fix(server): update generated sql queries * fix(e2e): tests for metadata face import feature * fix(web): Fix check:typescript * fix(e2e): update subproject ref * fix(server): revert format changes to pass format checks after ci * fix(mobile): update open-api * fix(server,movile,open-api,mobile): sourceType as DB data type * fix(e2e): upload face asset after enabling metadata face import * fix(web): simplify metadata admin settings and i18n keys * Update person.repository.ts Co-authored-by: Jason Rasmussen <jason@rasm.me> * fix(server): asset_faces.sourceType column not nullable * fix(server): simplified syntax * fix(e2e): use SDK for everything except the endpoint being tested * fix(e2e): fix test format * chore: clean up * chore: clean up * chore: update e2e/test-assets --------- Signed-off-by: BugFest <bugfest.dev@pm.me> Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com> Co-authored-by: Jason Rasmussen <jason@rasm.me>
2024-09-05 00:23:58 +02:00
-- PersonRepository.getDistinctNames
select distinct
2026-08-12 13:19:08 -04:00
on (lower("person"."name")) "person"."personGroupId",
"person"."name"
from
"person"
where
(
"person"."ownerId" = $1
and "person"."name" != $2
)
feat(server): Import face regions from metadata (#6455) * feat: faces-from-metadata - Import face regions from metadata Implements immich-app#1692. - OpenAPI spec changes to accomodate metadata face import configs. New settings to enable the feature. - Updates admin UI compoments - ML faces detection/recognition & Exif/Metadata faces compatibility Signed-off-by: BugFest <bugfest.dev@pm.me> * chore(web): remove unused file confirm-enable-import-faces * chore(web): format metadata-settings * fix(server): faces-from-metadata tests and format * fix(server): code refinements, nullable face asset sourceType * fix(server): Add RegionInfo to ImmichTags interface * fix(server): deleteAllFaces sourceType param can be undefined * fix(server): exiftool-vendored 27.0.0 moves readArgs into ExifToolOptions * fix(server): rename isImportFacesFromMetadataEnabled to isFaceImportEnabled * fix(server): simplify sourceType conditional * fix(server): small fixes * fix(server): handling sourceType * fix(server): sourceType enum * fix(server): refactor metadata applyTaggedFaces * fix(server): create/update signature changes * fix(server): reduce computational cost of Person.getManyByName * fix(server): use faceList instead of faceSet * fix(server): Skip regions without Name defined * fix(mobile): Update open-api (face assets feature changes) * fix(server): Face-Person reconciliation with map/index * fix(server): tags.RegionInfo.AppliedToDimensions must be defined to process face-region * fix(server): fix shared-link.service.ts format * fix(mobile): Update open-api after branch update * simplify * fix(server): minor fixes * fix(server): person create/update methods type enforcement * fix(server): style fixes * fix(server): remove unused metadata code * fix(server): metadata faces unit tests * fix(server): top level config metadata category * fix(server): rename upsertFaces to replaceFaces * fix(server): remove sourceType when unnecessary * fix(server): sourceType as ENUM * fix(server): format fixes * fix(server): fix tests after sourceType ENUM change * fix(server): remove unnecessary JobItem cast * fix(server): fix asset enum imports * fix(open-api): add metadata config * fix(mobile): update open-api after metadata open-api spec changes * fix(web): update web/api metadata config * fix(server): remove duplicated sourceType def * fix(server): update generated sql queries * fix(e2e): tests for metadata face import feature * fix(web): Fix check:typescript * fix(e2e): update subproject ref * fix(server): revert format changes to pass format checks after ci * fix(mobile): update open-api * fix(server,movile,open-api,mobile): sourceType as DB data type * fix(e2e): upload face asset after enabling metadata face import * fix(web): simplify metadata admin settings and i18n keys * Update person.repository.ts Co-authored-by: Jason Rasmussen <jason@rasm.me> * fix(server): asset_faces.sourceType column not nullable * fix(server): simplified syntax * fix(e2e): use SDK for everything except the endpoint being tested * fix(e2e): fix test format * chore: clean up * chore: clean up * chore: update e2e/test-assets --------- Signed-off-by: BugFest <bugfest.dev@pm.me> Co-authored-by: mertalev <101130780+mertalev@users.noreply.github.com> Co-authored-by: Jason Rasmussen <jason@rasm.me>
2024-09-05 00:23:58 +02:00
-- PersonRepository.getStatistics
select
2025-07-14 10:13:06 -04:00
count(distinct ("asset"."id")) as "count"
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
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
-- PersonRepository.getNumberOfPeople
select
coalesce(count(*), 0) as "total",
coalesce(
count(*) filter (
where
"isHidden" = $1
),
0
) as "hidden"
from
"person"
where
exists (
select
from
2025-07-14 10:13:06 -04:00
"asset_face"
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
and exists (
select
from
2025-07-14 10:13:06 -04:00
"asset"
where
2025-07-14 10:13:06 -04:00
"asset"."id" = "asset_face"."assetId"
and "asset"."visibility" = 'timeline'
and "asset"."deletedAt" is null
)
)
2026-01-09 17:59:52 -05:00
and "person"."ownerId" = $3
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
*
-- PersonRepository.refreshFaces
with
"added_embeddings" as (
insert into
"face_search" ("faceId", "embedding")
values
($1, $2)
)
select
from
(
select
1
) as "dummy"
-- PersonRepository.getFacesByIds
select
2025-07-14 10:13:06 -04:00
"asset_face".*,
(
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
) as obj
) as "person"
from
2025-07-14 10:13:06 -04:00
"asset_face"
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
-- PersonRepository.getRandomFace
select
2025-07-14 10:13:06 -04:00
"asset_face".*
from
2025-07-14 10:13:06 -04:00
"asset_face"
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
-- PersonRepository.getLatestFaceDate
select
max("asset_job_status"."facesRecognizedAt")::text as "latestDate"
from
"asset_job_status"
-- PersonRepository.deleteAssetFace
2025-07-14 10:13:06 -04:00
delete from "asset_face"
where
2025-07-14 10:13:06 -04:00
"asset_face"."id" = $1
-- PersonRepository.softDeleteAssetFaces
2025-07-14 10:13:06 -04:00
update "asset_face"
set
"deletedAt" = $1
where
2025-07-14 10:13:06 -04:00
"asset_face"."id" = $2
-- PersonRepository.getForPeopleDelete
select
2026-08-12 13:19:08 -04:00
"person"."ownerId",
"person"."personGroupId",
"person"."thumbnailPath"
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