Fixed bug in getting all the Tokens
MODIFY
src/client/ocpi/EmspOCPIClient.ts
src/client/ocpi/EmspOCPIClient.ts
@@ -38,7 +38,7 @@ import moment from 'moment';
const MODULE_NAME = 'EmspOCPIClient';
export default class EmspOCPIClient extends OCPIClient {
- constructor(tenant: Tenant, settings: OcpiSetting, ocpiEndpoint: OCPIEndpoint) {
+ public constructor(tenant: Tenant, settings: OcpiSetting, ocpiEndpoint: OCPIEndpoint) {
super(tenant, settings, ocpiEndpoint, OCPIRole.EMSP);
if (ocpiEndpoint.role !== OCPIRole.EMSP) {
throw new BackendError({
@@ -60,7 +60,7 @@ export default class EmspOCPIClient extends OCPIClient {
// Perfs trace
const startTime = new Date().getTime();
// Get timestamp before starting process - to be saved in DB at the end of the process
- const startDate = new Date();
+ const lastPatchJobOn = new Date();
// Get all tokens
const tokensResult = await OCPIUtilsService.getAllTokens(this.tenant, 0, 0);
for (const token of tokensResult.result) {
@@ -77,7 +77,7 @@ export default class EmspOCPIClient extends OCPIClient {
}
}
// Save result in ocpi endpoint
- this.ocpiEndpoint.lastPatchJobOn = startDate;
+ this.ocpiEndpoint.lastPatchJobOn = lastPatchJobOn;
// Set result
if (result) {
this.ocpiEndpoint.lastPatchJobResult = {

MODIFY
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/OCPIUtilsService.ts
src/server/ocpi/ocpi-services-impl/ocpi-2.1.1/OCPIUtilsService.ts
@@ -152,8 +152,13 @@ export default class OCPIUtilsService {
last_updated: tag.lastChangedOn ? tag.lastChangedOn : new Date()
});
}
+ let nbrOfTags = tags.count;
+ if (nbrOfTags === -1) {
+ const tagsCount = await TagStorage.getTags(tenant.id, { issuer: true, dateFrom, dateTo }, Constants.DB_PARAMS_COUNT_ONLY);
+ nbrOfTags = tagsCount.count;
+ }
return {
- count: tags.count,
+ count: nbrOfTags,
result: tokens
};
}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -37,7 +37,6 @@ import SiteStorage from '../../../../storage/mongodb/SiteStorage';
import SmartChargingFactory from '../../../../integration/smart-charging/SmartChargingFactory';
import { StatusCodes } from 'http-status-codes';
import TenantComponents from '../../../../types/TenantComponents';
-import TenantStorage from '../../../../storage/mongodb/TenantStorage';
import TransactionStorage from '../../../../storage/mongodb/TransactionStorage';
import UserStorage from '../../../../storage/mongodb/UserStorage';
import UserToken from '../../../../types/UserToken';

Fixed bug in getting all the Tokens