mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
refactor: query for fetching faces and people of assets (#17661)
* use json instead of jsonb * missing condition
This commit is contained in:
parent
ed2b54527c
commit
242a559e0f
2 changed files with 32 additions and 39 deletions
|
|
@ -87,22 +87,26 @@ select
|
|||
"assets".*,
|
||||
(
|
||||
select
|
||||
jsonb_agg(
|
||||
case
|
||||
when "person"."id" is not null then jsonb_insert(
|
||||
to_jsonb("asset_faces"),
|
||||
'{person}'::text[],
|
||||
to_jsonb("person")
|
||||
)
|
||||
else to_jsonb("asset_faces")
|
||||
end
|
||||
) as "faces"
|
||||
coalesce(json_agg(agg), '[]')
|
||||
from
|
||||
"asset_faces"
|
||||
left join "person" on "person"."id" = "asset_faces"."personId"
|
||||
where
|
||||
"asset_faces"."assetId" = "assets"."id"
|
||||
and "asset_faces"."deletedAt" is null
|
||||
(
|
||||
select
|
||||
"asset_faces".*,
|
||||
"person" as "person"
|
||||
from
|
||||
"asset_faces"
|
||||
left join lateral (
|
||||
select
|
||||
"person".*
|
||||
from
|
||||
"person"
|
||||
where
|
||||
"asset_faces"."personId" = "person"."id"
|
||||
) as "person" on true
|
||||
where
|
||||
"asset_faces"."assetId" = "assets"."id"
|
||||
and "asset_faces"."deletedAt" is null
|
||||
) as agg
|
||||
) as "faces",
|
||||
(
|
||||
select
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue