mirror of
https://github.com/immich-app/immich.git
synced 2025-12-20 09:15:35 +03:00
refactor: query for fetching faces and people of assets (#17661)
* use json instead of jsonb * missing condition
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user