Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ changes.

### Fixed

- Fix blank page on dRep details when link or identity references contain objects: { @value: ... } not strings [Issue 3733](https://github.com/IntersectMBO/govtool/issues/3733)
- Fix missing off chain references in DRep details [Issue 3490](https://github.com/IntersectMBO/govtool/issues/3490)
- Fix blank screen and type error on linkReferences when navigating to edit dRep page that has no links [Issue 3714](https://github.com/IntersectMBO/govtool/issues/3714)
- Fix adding two link input fields when editing the dRep form when no links are present initially [Issue 3709](https://github.com/IntersectMBO/govtool/issues/3709)
Expand Down
66 changes: 45 additions & 21 deletions govtool/backend/sql/list-dreps.sql
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ HasNonDeregisterVotingAnchor AS (
EXISTS (
SELECT 1
FROM drep_registration dr_sub
WHERE
WHERE
dr_sub.drep_hash_id = dr.drep_hash_id
AND dr_sub.voting_anchor_id IS NULL
AND COALESCE(dr_sub.deposit, 0) >= 0
Expand Down Expand Up @@ -129,12 +129,24 @@ DRepData AS (
off_chain_vote_drep_data.image_hash,
COALESCE(
(
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
THEN (ocvd.json::jsonb)->'body'->'references'
ELSE '[]'::jsonb
CASE
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
THEN (ocvd.json::jsonb)->'body'->'references'
ELSE '[]'::jsonb
END
) AS ref
WHERE ref->>'@type' = 'Identity'
Expand All @@ -143,12 +155,24 @@ DRepData AS (
) AS identity_references,
COALESCE(
(
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
THEN (ocvd.json::jsonb)->'body'->'references'
ELSE '[]'::jsonb
CASE
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
THEN (ocvd.json::jsonb)->'body'->'references'
ELSE '[]'::jsonb
END
) AS ref
WHERE ref->>'@type' = 'Link'
Expand Down Expand Up @@ -185,7 +209,7 @@ DRepData AS (
LEFT JOIN FetchError fetch_error ON fetch_error.voting_anchor_id = leva.voting_anchor_id
LEFT JOIN HasNonDeregisterVotingAnchor hndva ON hndva.drep_hash_id = dh.id
LEFT JOIN off_chain_vote_data ocvd ON ocvd.voting_anchor_id = leva.voting_anchor_id
LEFT JOIN off_chain_vote_drep_data ON off_chain_vote_drep_data.off_chain_vote_data_id = ocvd.id
LEFT JOIN off_chain_vote_drep_data ON off_chain_vote_drep_data.off_chain_vote_data_id = ocvd.id
LEFT JOIN voting_procedure ON voting_procedure.drep_voter = dh.id
LEFT JOIN tx voting_procedure_transaction ON voting_procedure_transaction.id = voting_procedure.tx_id
LEFT JOIN block voting_procedure_block ON voting_procedure_block.id = voting_procedure_transaction.block_id
Expand Down Expand Up @@ -244,21 +268,21 @@ DRepData AS (
(
SELECT jsonb_agg(ref)
FROM jsonb_array_elements(
CASE
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
THEN (ocvd.json::jsonb)->'body'->'references'
ELSE '[]'::jsonb
CASE
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
THEN (ocvd.json::jsonb)->'body'->'references'
ELSE '[]'::jsonb
END
) AS ref
WHERE ref->>'@type' = 'Identity'
),
(
SELECT jsonb_agg(ref)
FROM jsonb_array_elements(
CASE
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
THEN (ocvd.json::jsonb)->'body'->'references'
ELSE '[]'::jsonb
CASE
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
THEN (ocvd.json::jsonb)->'body'->'references'
ELSE '[]'::jsonb
END
) AS ref
WHERE ref->>'@type' = 'Link'
Expand All @@ -275,4 +299,4 @@ WHERE
objectives ILIKE ? OR
motivations ILIKE ? OR
qualifications ILIKE ?
)
)