Fixed push of tokens not working
MODIFY
src/client/ocpi/EmspOCPIClient.ts
src/client/ocpi/EmspOCPIClient.ts
@@ -6,6 +6,7 @@ import ChargingStationStorage from '../../storage/mongodb/ChargingStationStorage
import Company from '../../types/Company';
import CompanyStorage from '../../storage/mongodb/CompanyStorage';
import Constants from '../../utils/Constants';
+import { DataResult } from '../../types/DataResult';
import Logging from '../../utils/Logging';
import { OCPICdr } from '../../types/ocpi/OCPICdr';
import OCPIClient from './OCPIClient';
@@ -61,9 +62,13 @@ export default class EmspOCPIClient extends OCPIClient {
const startTime = new Date().getTime();
// Get timestamp before starting process - to be saved in DB at the end of the process
const lastPatchJobOn = new Date();
+ let currentSkip = 0;
+ let tokens: DataResult<OCPIToken>;
+ do {
// Get all tokens
- const tokensResult = await OCPIUtilsService.getAllTokens(this.tenant, 0, 0);
- for (const token of tokensResult.result) {
+ tokens = await OCPIUtilsService.getAllTokens(
+ this.tenant, Constants.DB_RECORD_COUNT_DEFAULT, currentSkip);
+ for (const token of tokens.result) {
result.total++;
try {
await this.pushToken(token);
@@ -76,6 +81,8 @@ export default class EmspOCPIClient extends OCPIClient {
);
}
}
+ currentSkip += Constants.DB_RECORD_COUNT_DEFAULT;
+ } while (!Utils.isEmptyArray(tokens.result));
// Save result in ocpi endpoint
this.ocpiEndpoint.lastPatchJobOn = lastPatchJobOn;
// Set result

Fixed push of tokens not working