Skip to content

Commit

Permalink
Fix helium-vote (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChewingGlass authored Jan 30, 2025
1 parent fcd864b commit 1d3a074
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
1 change: 0 additions & 1 deletion packages/account-postgres-sink-service/vehnt.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

WITH
readable_positions AS (
SELECT p.*,
Expand Down
10 changes: 8 additions & 2 deletions packages/helium-vote-service/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,10 @@ WITH
detail,
count(p.voter) as "numAssignments",
floor(sum(p.ve_tokens)) as "proxiedVeTokens",
100 * sum(p.ve_tokens) / (select total_vetokens from total_vetokens) as "percent"
CASE
WHEN (select total_vetokens from total_vetokens) = 0 THEN 0
ELSE 100 * sum(COALESCE(p.ve_tokens, 0)) / (select total_vetokens from total_vetokens)
END as "percent"
FROM
proxies
JOIN proxy_registrars pr ON pr.wallet = proxies.wallet
Expand Down Expand Up @@ -254,7 +257,10 @@ WITH
detail,
count(p.voter) as "numAssignments",
floor(sum(p.ve_tokens)) as "proxiedVeTokens",
100 * sum(p.ve_tokens) / (select total_vetokens from total_vetokens) as "percent"
CASE
WHEN (select total_vetokens from total_vetokens) = 0 THEN 0
ELSE 100 * sum(COALESCE(p.ve_tokens, 0)) / (select total_vetokens from total_vetokens)
END as "percent"
FROM
(SELECT DISTINCT voter as wallet FROM positions_with_proxy_assignments
UNION
Expand Down

0 comments on commit 1d3a074

Please sign in to comment.