Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,19 @@ DRepData AS (
off_chain_vote_drep_data.image_url,
off_chain_vote_drep_data.image_hash,
(
SELECT jsonb_agg(ref)
SELECT jsonb_agg(
jsonb_build_object(
'uri', COALESCE(
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
ref->'uri'->>'@value'
),
'@type', ref->>'@type',
'label', COALESCE(
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
ref->'label'->>'@value'
)
)
)
FROM jsonb_array_elements(
CASE
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
Expand All @@ -277,7 +289,19 @@ DRepData AS (
WHERE ref->>'@type' = 'Identity'
),
(
SELECT jsonb_agg(ref)
SELECT jsonb_agg(
jsonb_build_object(
'uri', COALESCE(
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
ref->'uri'->>'@value'
),
'@type', ref->>'@type',
'label', COALESCE(
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
ref->'label'->>'@value'
)
)
)
FROM jsonb_array_elements(
CASE
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
Expand Down