Skip to content

Commit

Permalink
Remove account from filters for transfers endpoint (#75)
Browse files Browse the repository at this point in the history
Fix #72

Signed-off-by: Etienne Donneger <[email protected]>
  • Loading branch information
0237h authored Sep 24, 2024
1 parent 75db1c6 commit 9d9024b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
let filters = "";
// Don't add `limit` and `block_range` to WHERE clause
for (const k of Object.keys(query_params).filter(k => k !== "limit" && k !== "block_range")) {
if (k === 'account' && endpoint === '/transfers/account')
continue;

const clickhouse_type = typeof query_params[k as keyof typeof query_params] === "number" ? "int" : "String";
if (k === 'symcode') // Special case to allow case-insensitive symcode input
filters += ` (${k} = upper({${k}: ${clickhouse_type}})) AND`;
Expand Down Expand Up @@ -86,8 +89,6 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use

query += ` ${filters} ORDER BY block_num DESC`;
} else if (endpoint == "/transfers/account") {
// Remove `account` from filters, only using it in the subquery
filters.replace('(account = {account: String})', '');
query +=
`SELECT * FROM`
+ ` (SELECT DISTINCT * FROM transfers_from WHERE ((from = {account: String}) OR (to = {account: String})))`
Expand Down

0 comments on commit 9d9024b

Please sign in to comment.