Skip to content

Commit

Permalink
fix(#2085): fix counting SPO votes
Browse files Browse the repository at this point in the history
  • Loading branch information
MSzalowski committed Oct 10, 2024
1 parent f9fdbd0 commit 16c48e5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 48 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ changes.

### Fixed

-
- Fix displaying the SPO Votes [Issue 2085](https://github.com/IntersectMBO/govtool/issues/2085)

### Changed

Expand Down
26 changes: 5 additions & 21 deletions govtool/backend/sql/list-proposals.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down
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" ? value : `₳ ${correctAdaFormat(value)}`}
</Typography>
</Box>
);
50 changes: 25 additions & 25 deletions govtool/frontend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1448,20 +1448,20 @@
resolved "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-asmjs/-/cardano-serialization-lib-asmjs-12.1.0.tgz"
integrity sha512-LVClEWmZmTvaXTBUpSOdyAYr10PlnfEycG1Z5m96aHWN08mdQH/x2LyZxuCjWVSusrG3ZwFnsOYZCHLel7tu4g==

"@esbuild/darwin-arm64@0.18.20":
"@esbuild/linux-x64@0.18.20":
version "0.18.20"
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.18.20.tgz"
integrity sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.18.20.tgz"
integrity sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==

"@esbuild/darwin-arm64@0.19.12":
"@esbuild/linux-x64@0.19.12":
version "0.19.12"
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.19.12.tgz"
integrity sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.19.12.tgz"
integrity sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==

"@esbuild/darwin-arm64@0.21.5":
"@esbuild/linux-x64@0.21.5":
version "0.21.5"
resolved "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz"
integrity sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==
resolved "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz"
integrity sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==

"@eslint-community/eslint-utils@^4.2.0", "@eslint-community/eslint-utils@^4.4.0":
version "4.4.0"
Expand Down Expand Up @@ -2666,10 +2666,15 @@
estree-walker "^2.0.2"
picomatch "^2.3.1"

"@rollup/rollup-darwin-arm64@4.21.2":
"@rollup/rollup-linux-x64-gnu@4.21.2":
version "4.21.2"
resolved "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.21.2.tgz"
integrity sha512-99AhQ3/ZMxU7jw34Sq8brzXqWH/bMnf7ZVhvLk9QU2cOepbQSVTns6qoErJmSiAvU3InRqC2RRZ5ovh1KN0d0Q==
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.2.tgz"
integrity sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw==

"@rollup/rollup-linux-x64-musl@4.21.2":
version "4.21.2"
resolved "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.2.tgz"
integrity sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg==

"@rushstack/eslint-patch@^1.1.0":
version "1.10.4"
Expand Down Expand Up @@ -3690,10 +3695,15 @@
"@svgr/plugin-svgo" "^5.5.0"
loader-utils "^2.0.0"

"@swc/core-darwin-arm64@1.7.22":
"@swc/core-linux-x64-gnu@1.7.22":
version "1.7.22"
resolved "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.7.22.tgz"
integrity sha512-639kA7MXrWqWYfwuSJ+XTg21VYb/5o99R1zJrndoEjEX6m7Wza/sXssQKU5jbbkPoSEKVKNP3n/gazLWiUKgiQ==

"@swc/core-linux-x64-musl@1.7.22":
version "1.7.22"
resolved "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.7.22.tgz"
integrity sha512-B2Bh2W+C7ALdGwDxRWAJ+UtNExfozvwyayGiNkbR3wmDKXXeQfhGM5MK+QYUWKu7UQ6ATq69OyZrxofDobKUug==
resolved "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.7.22.tgz"
integrity sha512-f3zfGgY8EJQUOk3ve25ZTkNkhB/kHo9QlN2r+0exaE1g9W7X8IS6J8pWzF3hJrV2P9dBi6ofMOt+opVA89JKHA==

"@swc/core@*", "@swc/core@^1.3.18":
version "1.7.22"
Expand Down Expand Up @@ -8455,16 +8465,6 @@ fs.realpath@^1.0.0:
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==

fsevents@^2.3.2, fsevents@~2.3.2, fsevents@~2.3.3:
version "2.3.3"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz"
integrity sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==

fsevents@2.3.2:
version "2.3.2"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==

function-bind@^1.1.2:
version "1.1.2"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz"
Expand Down

0 comments on commit 16c48e5

Please sign in to comment.