Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Fix tag operations
Browse files Browse the repository at this point in the history
  • Loading branch information
TheLoneRonin committed Apr 8, 2021
1 parent 10d8c3a commit 5b0369a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
19 changes: 3 additions & 16 deletions src/graphql/query.graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export async function generateQuery(params: QueryParams): Promise<QueryBuilder>

if (tags) {
const tagsConverted = tagToB64(tags);

for (let i = 0; i < tagsConverted.length; i++) {
const tag = tagsConverted[i];
const tagAlias = `${i}_${i}`;
Expand All @@ -81,14 +82,7 @@ export async function generateQuery(params: QueryParams): Promise<QueryBuilder>

if (tag.name === index) {
indexed = true;

if (tag.op === 'EQ') {
query.whereIn(`transactions.${index}`, tag.values);
}

if (tag.op === 'NEQ') {
query.whereNotIn(`transactions.${index}`, tag.values);
}
query.whereIn(`transactions.${index}`, tag.values);
}
}

Expand All @@ -97,14 +91,7 @@ export async function generateQuery(params: QueryParams): Promise<QueryBuilder>
join.on('transactions.id', `${tagAlias}.tx_id`);

join.andOnIn(`${tagAlias}.name`, [tag.name]);

if (tag.op === 'EQ') {
join.andOnIn(`${tagAlias}.value`, tag.values);
}

if (tag.op === 'NEQ') {
join.andOnNotIn(`${tagAlias}.value`, tag.values);
}
join.andOnIn(`${tagAlias}.value`, tag.values);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/query/transaction.query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export function tagToB64(tags: Array<TagFilter>): Array<TagFilter> {
const tag = tags[i];
conversion.push({
name: toB64url(tag.name),
values: tag.values.map(v => toB64url(v)),
values: tag.values.map((v) => toB64url(v)),
});
}

Expand Down

0 comments on commit 5b0369a

Please sign in to comment.