Skip to content

Commit a5b5dd9

Browse files
authored
Merge pull request #2616 from IntersectMBO/fix/2609-spo-vote-total-on-mainnet-is-incorrect
fix(#2609): fix wrong SPO vote totals
2 parents db747ed + 0f647be commit a5b5dd9

File tree

9 files changed

+209
-192
lines changed

9 files changed

+209
-192
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ changes.
1616

1717
### Fixed
1818

19-
-
19+
- Fix counting submitted votes [Issue 2609](https://github.com/IntersectMBO/govtool/issues/2609)
2020

2121
### Changed
2222

govtool/backend/sql/get-network-metrics.sql

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,16 @@ total_stake_controlled_by_dreps AS (
8383
SUM(dd.amount)::bigint AS total
8484
FROM
8585
drep_distr dd
86+
WHERE
87+
dd.epoch_no = (SELECT no FROM current_epoch)
88+
),
89+
total_stake_controlled_by_spos AS (
90+
SELECT
91+
SUM(ps.stake)::bigint AS total
92+
FROM
93+
pool_stat ps
94+
WHERE
95+
ps.epoch_no = (SELECT no FROM current_epoch)
8696
),
8797
total_registered_direct_voters AS (
8898
SELECT
@@ -176,6 +186,7 @@ SELECT
176186
total_drep_votes.count as total_drep_votes,
177187
total_registered_dreps.unique_registrations as total_registered_dreps,
178188
COALESCE(total_stake_controlled_by_dreps.total, 0) as total_stake_controlled_by_dreps,
189+
COALESCE(total_stake_controlled_by_spos.total, 0) as total_stake_controlled_by_spos,
179190
total_active_dreps.unique_active_drep_registrations as total_active_dreps,
180191
total_inactive_dreps.total_inactive_dreps as total_inactive_dreps,
181192
total_active_cip119_compliant_dreps.unique_active_cip119_compliant_drep_registrations as total_active_cip119_compliant_dreps,
@@ -192,6 +203,7 @@ FROM
192203
CROSS JOIN total_drep_votes
193204
CROSS JOIN total_registered_dreps
194205
CROSS JOIN total_stake_controlled_by_dreps
206+
CROSS JOIN total_stake_controlled_by_spos
195207
CROSS JOIN total_active_dreps
196208
CROSS JOIN total_inactive_dreps
197209
CROSS JOIN total_active_cip119_compliant_dreps
@@ -208,6 +220,7 @@ GROUP BY
208220
total_drep_votes.count,
209221
total_registered_dreps.unique_registrations,
210222
total_stake_controlled_by_dreps.total,
223+
total_stake_controlled_by_spos.total,
211224
total_active_dreps.unique_active_drep_registrations,
212225
total_inactive_dreps.total_inactive_dreps,
213226
total_active_cip119_compliant_dreps.unique_active_cip119_compliant_drep_registrations,

0 commit comments

Comments
 (0)