Skip to content

Commit

Permalink
Add balance null check to filters
Browse files Browse the repository at this point in the history
  • Loading branch information
0237h committed Jan 17, 2025
1 parent ef3575e commit 6a4a45f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
}

if (endpoint == "/account/balances") {
filters += ` AND has_null_balance = 0`;
query +=
`SELECT block_num AS last_updated_block, contract, symcode, value as balance FROM token_holders FINAL`
+ ` ${filters} ORDER BY value DESC`
Expand Down Expand Up @@ -103,6 +104,7 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
} else if (endpoint == "/transfers/id") {
query += `SELECT * FROM transfer_events ${filters} ORDER BY action_index`;
} else if (endpoint == "/tokens/holders") {
filters += ` AND has_null_balance = 0`;
query += `SELECT account, value AS balance FROM token_holders FINAL ${filters} ORDER BY value DESC`;
} else if (endpoint == "/head") {
query += `SELECT block_num, block_id FROM cursors FINAL`;
Expand Down

0 comments on commit 6a4a45f

Please sign in to comment.