Skip to content

Commit

Permalink
statisticsV2 - fix grouped tx resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
ashkuc committed Sep 6, 2023
1 parent ea0e78d commit a1924fa
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion apps/web-api/src/statisticsV2/statisticsV2.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ export class StatisticsV2Resolver {
public async extrinsicsGroupedByInterval(
@Args() args: GroupedEventsInputDto,
): Promise<GroupedEventsResponse> {
return this.service.getEventsGroupedByInterval(args);
return this.service.getExtrinsicsGroupedByInterval(args);
}
}
23 changes: 23 additions & 0 deletions apps/web-api/src/statisticsV2/statisticsV2.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,29 @@ export class StatisticsV2Service {
};
}

async getExtrinsicsGroupedByInterval(
groupedEventsInput: GroupedEventsInputDto,
): Promise<GroupedEventsResponse> {
const args = fillGroupedEventsInput(groupedEventsInput);
const rawItems = await this.statisticsV2Repository.countGroupedExtrinsics(
args,
);

const items = rawItems.map((item) => ({
intervalTimestamp: dateToTimestamp(
args.timestampType,
item.interval_timestamp,
),
count: parseInt(item.event_count, 10),
}));

return {
items,
groupByInterval: args.groupByInterval,
timestampType: args.timestampType,
};
}

private async withCache<T>(key: string, fn: () => Promise<T>): Promise<T> {
const cached = await this.cache.get<T>(key);

Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polkastats-backend-uniquenetwork",
"version": "2.0.68",
"version": "2.0.69",
"description": "",
"author": "Unique Network Team",
"private": true,
Expand Down

0 comments on commit a1924fa

Please sign in to comment.