Skip to content

Commit

Permalink
Merge pull request #2144 from IntersectMBO/test
Browse files Browse the repository at this point in the history
1.0.21-rc Governance Actions dates and SPO votes fixes
  • Loading branch information
MSzalowski authored Oct 15, 2024
2 parents 19ca88a + 450febe commit a8e0e61
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 31 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 8 additions & 6 deletions govtool/backend/sql/get-stake-key-voting-power.sql
Original file line number Diff line number Diff line change
@@ -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;
41 changes: 18 additions & 23 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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),
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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)
prev_gov_action_tx.hash,
meta.network_name)
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ const Vote = ({ type, vote, value }: VoteProps) => (
wordBreak: "break-all",
}}
>
{type === "dReps" ? `₳ ${correctAdaFormat(value)}` : value}
{type !== "ccCommittee" ? `₳ ${correctAdaFormat(value)}` : value}
</Typography>
</Box>
);

0 comments on commit a8e0e61

Please sign in to comment.