Skip to content

Commit

Permalink
fix: holders count query (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelcr authored Sep 1, 2023
1 parent 0311262 commit 254ed75
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/pg/brc20/brc20-pg-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,13 +342,13 @@ export class Brc20PgStore extends BasePgStoreModule {
WHERE ticker_lower = LOWER(${args.ticker})
),
holders AS (
SELECT COUNT(*) AS count
SELECT 1 AS holder
FROM brc20_balances
WHERE brc20_deploy_id = (SELECT id FROM token)
GROUP BY address
HAVING SUM(avail_balance + trans_balance) > 0
)
SELECT *, COALESCE((SELECT count FROM holders), 0) AS holders
SELECT *, COALESCE((SELECT COUNT(*) FROM holders), 0) AS holders
FROM token
`;
if (result.count) return result[0];
Expand Down

0 comments on commit 254ed75

Please sign in to comment.