Skip to content

Commit

Permalink
MEX-662: Added Size as a parameter for getTokenTradingEvents
Browse files Browse the repository at this point in the history
  • Loading branch information
EmanuelMiron committed Jan 30, 2025
1 parent 9af8f25 commit a762d26
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions src/modules/analytics/services/analytics.compute.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ export class AnalyticsComputeService {
const filteredEvents: RawElasticEventType[] = [];
const pairsAddresses = await this.routerAbi.pairsAddress();
let latestTimestamp = Math.floor(Date.now() / 1000);
const size = 50;

const createUniqueIdentifier = (event: RawElasticEventType) => {
return `${event.txHash}-${event.shardID}-${event.order}`;
Expand All @@ -398,6 +399,7 @@ export class AnalyticsComputeService {
await this.elasticEventsService.getTokenTradingEvents(
tokenID,
latestTimestamp,
size,
);
filteredEvents.push(
...events
Expand All @@ -413,6 +415,9 @@ export class AnalyticsComputeService {
.slice(0, 10),
);
latestTimestamp = filteredEvents[0].timestamp;
if (filteredEvents.length < size) {
break;
}
}

return filteredEvents.map((event) => {
Expand Down
3 changes: 2 additions & 1 deletion src/services/elastic-search/services/es.events.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,10 @@ export class ElasticSearchEventsService {
async getTokenTradingEvents(
tokenID: string,
timestamp: number,
size: number,
): Promise<RawElasticEventType[]> {
const pagination = new ElasticPagination();
pagination.size = 50;
pagination.size = size;

const elasticQueryAdapter: ElasticQuery =
new ElasticQuery().withPagination(pagination);
Expand Down

0 comments on commit a762d26

Please sign in to comment.