Skip to content

Commit 2d3a82c

Browse files
authored
Merge pull request #3737 from IntersectMBO/3733-bug-drep-details-page-produces-blank-screen-with-console-error
fix(#3733): blank page when dRep have @value in uri or label references
2 parents 450afb1 + 44f29dc commit 2d3a82c

File tree

2 files changed

+46
-21
lines changed

2 files changed

+46
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ changes.
1616

1717
### Fixed
1818

19+
- 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)
1920
- Fix missing off chain references in DRep details [Issue 3490](https://github.com/IntersectMBO/govtool/issues/3490)
2021
- 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)
2122
- 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)

govtool/backend/sql/list-dreps.sql

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ HasNonDeregisterVotingAnchor AS (
9595
EXISTS (
9696
SELECT 1
9797
FROM drep_registration dr_sub
98-
WHERE
98+
WHERE
9999
dr_sub.drep_hash_id = dr.drep_hash_id
100100
AND dr_sub.voting_anchor_id IS NULL
101101
AND COALESCE(dr_sub.deposit, 0) >= 0
@@ -129,12 +129,24 @@ DRepData AS (
129129
off_chain_vote_drep_data.image_hash,
130130
COALESCE(
131131
(
132-
SELECT jsonb_agg(ref)
132+
SELECT jsonb_agg(
133+
jsonb_build_object(
134+
'uri', COALESCE(
135+
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
136+
ref->'uri'->>'@value'
137+
),
138+
'@type', ref->>'@type',
139+
'label', COALESCE(
140+
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
141+
ref->'label'->>'@value'
142+
)
143+
)
144+
)
133145
FROM jsonb_array_elements(
134-
CASE
135-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
136-
THEN (ocvd.json::jsonb)->'body'->'references'
137-
ELSE '[]'::jsonb
146+
CASE
147+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
148+
THEN (ocvd.json::jsonb)->'body'->'references'
149+
ELSE '[]'::jsonb
138150
END
139151
) AS ref
140152
WHERE ref->>'@type' = 'Identity'
@@ -143,12 +155,24 @@ DRepData AS (
143155
) AS identity_references,
144156
COALESCE(
145157
(
146-
SELECT jsonb_agg(ref)
158+
SELECT jsonb_agg(
159+
jsonb_build_object(
160+
'uri', COALESCE(
161+
CASE WHEN jsonb_typeof(ref->'uri') = 'string' THEN ref->>'uri' END,
162+
ref->'uri'->>'@value'
163+
),
164+
'@type', ref->>'@type',
165+
'label', COALESCE(
166+
CASE WHEN jsonb_typeof(ref->'label') = 'string' THEN ref->>'label' END,
167+
ref->'label'->>'@value'
168+
)
169+
)
170+
)
147171
FROM jsonb_array_elements(
148-
CASE
149-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
150-
THEN (ocvd.json::jsonb)->'body'->'references'
151-
ELSE '[]'::jsonb
172+
CASE
173+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
174+
THEN (ocvd.json::jsonb)->'body'->'references'
175+
ELSE '[]'::jsonb
152176
END
153177
) AS ref
154178
WHERE ref->>'@type' = 'Link'
@@ -185,7 +209,7 @@ DRepData AS (
185209
LEFT JOIN FetchError fetch_error ON fetch_error.voting_anchor_id = leva.voting_anchor_id
186210
LEFT JOIN HasNonDeregisterVotingAnchor hndva ON hndva.drep_hash_id = dh.id
187211
LEFT JOIN off_chain_vote_data ocvd ON ocvd.voting_anchor_id = leva.voting_anchor_id
188-
LEFT JOIN off_chain_vote_drep_data ON off_chain_vote_drep_data.off_chain_vote_data_id = ocvd.id
212+
LEFT JOIN off_chain_vote_drep_data ON off_chain_vote_drep_data.off_chain_vote_data_id = ocvd.id
189213
LEFT JOIN voting_procedure ON voting_procedure.drep_voter = dh.id
190214
LEFT JOIN tx voting_procedure_transaction ON voting_procedure_transaction.id = voting_procedure.tx_id
191215
LEFT JOIN block voting_procedure_block ON voting_procedure_block.id = voting_procedure_transaction.block_id
@@ -244,21 +268,21 @@ DRepData AS (
244268
(
245269
SELECT jsonb_agg(ref)
246270
FROM jsonb_array_elements(
247-
CASE
248-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
249-
THEN (ocvd.json::jsonb)->'body'->'references'
250-
ELSE '[]'::jsonb
271+
CASE
272+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
273+
THEN (ocvd.json::jsonb)->'body'->'references'
274+
ELSE '[]'::jsonb
251275
END
252276
) AS ref
253277
WHERE ref->>'@type' = 'Identity'
254278
),
255279
(
256280
SELECT jsonb_agg(ref)
257281
FROM jsonb_array_elements(
258-
CASE
259-
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
260-
THEN (ocvd.json::jsonb)->'body'->'references'
261-
ELSE '[]'::jsonb
282+
CASE
283+
WHEN (ocvd.json::jsonb)->'body'->'references' IS NOT NULL
284+
THEN (ocvd.json::jsonb)->'body'->'references'
285+
ELSE '[]'::jsonb
262286
END
263287
) AS ref
264288
WHERE ref->>'@type' = 'Link'
@@ -275,4 +299,4 @@ WHERE
275299
objectives ILIKE ? OR
276300
motivations ILIKE ? OR
277301
qualifications ILIKE ?
278-
)
302+
)

0 commit comments

Comments
 (0)