Skip to content

Commit 3e820a6

Browse files
author
Adam Tomaszczyk
committed
Fix SQL counting the number of active CC members - additional fix for preview
1 parent d9eff0d commit 3e820a6

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,18 @@ CurrentEpoch AS (
2222
SELECT MAX(no) AS no FROM epoch
2323
),
2424
CommitteeMembers AS (
25-
SELECT DISTINCT ON (cm.committee_hash_id)
26-
cm.id,
27-
cm.expiration_epoch
25+
SELECT
26+
DISTINCT cm.committee_hash_id AS committee_members
2827
FROM committee_member cm
29-
CROSS JOIN CurrentEpoch
30-
WHERE
31-
cm.expiration_epoch >= CurrentEpoch.no
28+
JOIN committee c ON c.id = cm.committee_id
29+
LEFT JOIN gov_action_proposal gap ON gap.id = c.gov_action_proposal_id
30+
CROSS JOIN CurrentEpoch ce
31+
WHERE (
32+
(c.gov_action_proposal_id IS NULL)
33+
OR
34+
(gap.enacted_epoch IS NOT NULL AND gap.enacted_epoch <= ce.no)
35+
)
36+
AND cm.expiration_epoch >= ce.no
3237
),
3338
NoOfCommitteeMembers AS (
3439
SELECT COUNT(*) total FROM CommitteeMembers

0 commit comments

Comments
 (0)