diff --git a/CHANGELOG.md b/CHANGELOG.md index 065341b36..fba49167e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,9 @@ 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) +- Fix counting ada holder voting power [Issue 2000](https://github.com/IntersectMBO/govtool/issues/2000) ### Changed diff --git a/govtool/backend/sql/get-stake-key-voting-power.sql b/govtool/backend/sql/get-stake-key-voting-power.sql index 59aa5049b..3c8f44020 100644 --- a/govtool/backend/sql/get-stake-key-voting-power.sql +++ b/govtool/backend/sql/get-stake-key-voting-power.sql @@ -1,6 +1,8 @@ -select coalesce(sum(utxo_view.value), 0), encode(stake_address.hash_raw, 'hex') -from stake_address -join utxo_view -on utxo_view.stake_address_id = stake_address.id -where stake_address.hash_raw = decode(?, 'hex') -group by stake_address.hash_raw +SELECT COALESCE(SUM(utxo_view.value::numeric), 0) + COALESCE(SUM(reward_rest.amount), 0) AS total_value, + encode(stake_address.hash_raw, 'hex') +FROM stake_address +JOIN utxo_view ON utxo_view.stake_address_id = stake_address.id +LEFT JOIN reward_rest ON reward_rest.addr_id = stake_address.id +WHERE reward_rest.earned_epoch IS NULL +WHERE stake_address.hash_raw = decode(?, 'hex') +GROUP BY stake_address.hash_raw; \ No newline at end of file diff --git a/govtool/backend/sql/list-proposals.sql b/govtool/backend/sql/list-proposals.sql index 7926fd6ba..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, @@ -78,9 +87,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), @@ -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 @@ -104,21 +114,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 +156,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, @@ -177,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 diff --git a/govtool/frontend/src/components/molecules/VotesSubmitted.tsx b/govtool/frontend/src/components/molecules/VotesSubmitted.tsx index 14aa7d0c0..7731767c7 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" ? `₳ ${correctAdaFormat(value)}` : value} );