Skip to content

Commit 445b8d7

Browse files
committed
(fix#3745) Repetition of authors on gov action details page
1 parent 7886412 commit 445b8d7

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

govtool/backend/sql/list-proposals.sql

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,19 @@ SELECT
306306
encode(prev_gov_action_tx.hash, 'hex') as prev_gov_action_tx_hash,
307307
off_chain_vote_data.json as json_content,
308308
COALESCE(
309-
json_agg(
310-
json_build_object(
311-
'name', off_chain_vote_author.name,
312-
'witnessAlgorithm', off_chain_vote_author.witness_algorithm,
313-
'publicKey', off_chain_vote_author.public_key,
314-
'signature', off_chain_vote_author.signature
315-
)
316-
) FILTER (WHERE off_chain_vote_author.id IS NOT NULL),
317-
'[]'
318-
) authors
309+
(
310+
SELECT jsonb_agg(
311+
jsonb_build_object(
312+
'name', author_elem->>'name',
313+
'publicKey', author_elem->'witness'->>'publicKey',
314+
'signature', author_elem->'witness'->>'signature',
315+
'witnessAlgorithm', author_elem->'witness'->>'witnessAlgorithm'
316+
)
317+
)
318+
FROM jsonb_array_elements(off_chain_vote_data.json->'authors') AS author_elem
319+
),
320+
'[]'::jsonb
321+
) AS authors
319322
FROM
320323
gov_action_proposal
321324
JOIN ActiveProposals ON gov_action_proposal.id = ActiveProposals.id
@@ -326,7 +329,6 @@ FROM
326329
LEFT JOIN block AS creator_block ON creator_block.id = creator_tx.block_id
327330
LEFT JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_id
328331
LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = voting_anchor.id
329-
lEFT JOIN off_chain_vote_author ON off_chain_vote_author.off_chain_vote_data_id = off_chain_vote_data.id
330332
LEFT JOIN off_chain_vote_gov_action_data ON off_chain_vote_gov_action_data.off_chain_vote_data_id = off_chain_vote_data.id
331333
LEFT JOIN param_proposal AS proposal_params ON gov_action_proposal.param_proposal = proposal_params.id
332334
LEFT JOIN cost_model AS cost_model ON proposal_params.cost_model_id = cost_model.id

0 commit comments

Comments
 (0)