Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove account from filters for transfers endpoint #75

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading