Skip to content

Commit

Permalink
Parse identical from/to for block_range transfers (#45)
Browse files Browse the repository at this point in the history
Apply the filter `OR` parsing in case of identical `from`/`to` also
in the case of supplying a `block_range`.
  • Loading branch information
0237h authored Jun 27, 2024
1 parent e358396 commit fa58168
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/usage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
query += `SELECT * FROM `;

const q = query_params as ValidUserParams<typeof endpoint>;
// Find all incoming and outgoing transfers from single account
if (q.from && q.to && q.from === q.to)
filters = filters.replace(
"(from = {from: String}) AND (to = {to: String})",
"((from = {from: String}) OR (to = {to: String}))",
)

if (q.block_range) {
query += `${database}.transfers_block_num`;
console.log(q.block_range);
Expand All @@ -71,13 +78,6 @@ export async function makeUsageQuery(ctx: Context, endpoint: UsageEndpoints, use
additional_query_params.min_block = q.block_range[0];
}
} else if (q.from) {
// Find all incoming and outgoing transfers from single account
if (q.to && q.to === q.from)
filters = filters.replace(
"(from = {from: String}) AND (to = {to: String})",
"((from = {from: String}) OR (to = {to: String}))",
)

query += `${database}.transfers_from`;
} else if (q.to) {
query += `${database}.transfers_to`;
Expand Down

0 comments on commit fa58168

Please sign in to comment.