Skip to content

Commit

Permalink
Merge pull request #416 from g-ongenae/fixture/stop-fetching-transact…
Browse files Browse the repository at this point in the history
…ion-if-no-new

[FIX] Stop fetching transactions if no new
  • Loading branch information
g-ongenae authored Oct 18, 2023
2 parents 5caac8f + 277d100 commit 2a98670
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/hooks/services/hooks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -342,10 +342,13 @@ export class HooksService {

let lastUpdatedAt: string | undefined;
let firstTransactionDate: moment.Moment = moment();
let nbOfTransactions: number = 0;
const transactionByAggregatorId: Map<string, BridgeTransaction> = new Map<string, BridgeTransaction>();
const getUniqueKey = (transaction: BridgeTransaction): string => `${transaction.account_id}_${transaction.id}`;

do {
nbOfTransactions = transactionByAggregatorId.size;

const fetchedTransactions: BridgeTransaction[] = await this.aggregator.getTransactions(
accessToken,
lastUpdatedAt,
Expand Down Expand Up @@ -375,6 +378,7 @@ export class HooksService {
}
}
} while (
nbOfTransactions < transactionByAggregatorId.size &&
moment().diff(firstTransactionDate, 'months') <= nbOfMonths &&
moment().isBefore(timeout) &&
(await delay(this.config.bridge.synchronizationWaitingTime, { value: true }))
Expand Down

0 comments on commit 2a98670

Please sign in to comment.