From 54d7fca2c7534eed45efec2ecfbd03e59f6bc456 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Thu, 10 Oct 2024 12:26:07 +0200 Subject: [PATCH 1/2] fix(#2085): fix counting the SPO votes --- CHANGELOG.md | 2 +- govtool/backend/sql/list-proposals.sql | 26 ++++--------------- .../components/molecules/VotesSubmitted.tsx | 2 +- 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 065341b36..f31b60357 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ changes. ### Fixed -- +- Fix displaying the SPO Votes [Issue 2085](https://github.com/IntersectMBO/govtool/issues/2085) ### Changed diff --git a/govtool/backend/sql/list-proposals.sql b/govtool/backend/sql/list-proposals.sql index 7926fd6ba..ae9945c91 100644 --- a/govtool/backend/sql/list-proposals.sql +++ b/govtool/backend/sql/list-proposals.sql @@ -78,9 +78,9 @@ SELECT always_no_confidence_voting_power.amount END) "no_votes", coalesce(Sum(ldd_drep.amount) FILTER (WHERE voting_procedure.vote::text = 'Abstain'), 0) + always_abstain_voting_power.amount "abstain_votes", - coalesce(vp_by_pool.poolYesVotes, 0), - coalesce(vp_by_pool.poolNoVotes, 0), - coalesce(vp_by_pool.poolAbstainVotes, 0), + coalesce(Sum(ldd_pool.amount) FILTER (WHERE voting_procedure.vote::text = 'Yes'), 0), + coalesce(Sum(ldd_pool.amount) FILTER (WHERE voting_procedure.vote::text = 'No'), 0), + coalesce(Sum(ldd_pool.amount) FILTER (WHERE voting_procedure.vote::text = 'Abstain'), 0), coalesce(vp_by_cc.ccYesVotes, 0), coalesce(vp_by_cc.ccNoVotes, 0), coalesce(vp_by_cc.ccAbstainVotes, 0), @@ -104,21 +104,8 @@ FROM LEFT JOIN voting_procedure ON voting_procedure.gov_action_proposal_id = gov_action_proposal.id LEFT JOIN LatestDrepDistr ldd_drep ON ldd_drep.hash_id = voting_procedure.drep_voter AND ldd_drep.rn = 1 - LEFT JOIN - ( - SELECT - gov_action_proposal_id, - SUM(CASE WHEN vote = 'Yes' THEN 1 ELSE 0 END) AS poolYesVotes, - SUM(CASE WHEN vote = 'No' THEN 1 ELSE 0 END) AS poolNoVotes, - SUM(CASE WHEN vote = 'Abstain' THEN 1 ELSE 0 END) AS poolAbstainVotes - FROM - voting_procedure - WHERE - pool_voter IS NOT NULL - GROUP BY - gov_action_proposal_id - ) vp_by_pool - ON gov_action_proposal.id = vp_by_pool.gov_action_proposal_id + LEFT JOIN LatestDrepDistr ldd_pool ON ldd_pool.hash_id = voting_procedure.pool_voter + AND ldd_pool.rn = 1 LEFT JOIN ( SELECT @@ -159,9 +146,6 @@ GROUP BY off_chain_vote_gov_action_data.abstract, off_chain_vote_gov_action_data.motivation, off_chain_vote_gov_action_data.rationale, - vp_by_pool.poolYesVotes, - vp_by_pool.poolNoVotes, - vp_by_pool.poolAbstainVotes, vp_by_cc.ccYesVotes, vp_by_cc.ccNoVotes, vp_by_cc.ccAbstainVotes, diff --git a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx index 14aa7d0c0..94390f9fc 100644 --- a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx +++ b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx @@ -150,7 +150,7 @@ const Vote = ({ type, vote, value }: VoteProps) => ( wordBreak: "break-all", }} > - {type === "dReps" ? `₳ ${correctAdaFormat(value)}` : value} + {type !== "ccCommittee" ? value : `₳ ${correctAdaFormat(value)}`} ); From 3a5d163e5bb0835e19dcc59e81841d40a134c2f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Sza=C5=82owski?= Date: Thu, 10 Oct 2024 14:20:03 +0200 Subject: [PATCH 2/2] fix(#2125): fix counting governance action expiration --- CHANGELOG.md | 1 + govtool/backend/sql/list-proposals.sql | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f31b60357..c05300ca2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ changes. ### Fixed +- Fix counting epoch boundaries for Governance Actions [Issue 2125](https://github.com/IntersectMBO/govtool/issues/2125) - Fix displaying the SPO Votes [Issue 2085](https://github.com/IntersectMBO/govtool/issues/2085) ### Changed diff --git a/govtool/backend/sql/list-proposals.sql b/govtool/backend/sql/list-proposals.sql index ae9945c91..e2077026b 100644 --- a/govtool/backend/sql/list-proposals.sql +++ b/govtool/backend/sql/list-proposals.sql @@ -54,7 +54,16 @@ SELECT null end ) as description, - epoch_utils.last_epoch_end_time + epoch_utils.epoch_duration * (gov_action_proposal.expiration - epoch_utils.last_epoch_no), + CASE + WHEN meta.network_name::text = 'mainnet' THEN + epoch_utils.last_epoch_end_time + + epoch_utils.epoch_duration * (gov_action_proposal.expiration - epoch_utils.last_epoch_no)::bigint + + INTERVAL '5 days' + ELSE + epoch_utils.last_epoch_end_time + + epoch_utils.epoch_duration * (gov_action_proposal.expiration - epoch_utils.last_epoch_no)::bigint + + INTERVAL '1 day' + END AS expiry_date, gov_action_proposal.expiration, creator_block.time, creator_block.epoch_no, @@ -95,6 +104,7 @@ FROM CROSS JOIN EpochUtils AS epoch_utils CROSS JOIN always_no_confidence_voting_power CROSS JOIN always_abstain_voting_power + CROSS JOIN meta JOIN tx AS creator_tx ON creator_tx.id = gov_action_proposal.tx_id JOIN block AS creator_block ON creator_block.id = creator_tx.block_id LEFT JOIN voting_anchor ON voting_anchor.id = gov_action_proposal.voting_anchor_id @@ -161,4 +171,5 @@ GROUP BY always_no_confidence_voting_power.amount, always_abstain_voting_power.amount, prev_gov_action.index, - prev_gov_action_tx.hash) \ No newline at end of file + prev_gov_action_tx.hash, + meta.network_name) \ No newline at end of file