Pull the last 2 weeks eMSP Cdrs/Sessions when triggered manually
MODIFY
src/client/ocpi/EmspOCPIClient.ts
src/client/ocpi/EmspOCPIClient.ts
@@ -268,7 +268,7 @@ export default class EmspOCPIClient extends OCPIClient {
return result;
}
- public async pullSessions(): Promise<OCPIResult> {
+ public async pullSessions(partial = false): Promise<OCPIResult> {
// Result
const result: OCPIResult = {
success: 0,
@@ -280,7 +280,14 @@ export default class EmspOCPIClient extends OCPIClient {
const startTime = new Date().getTime();
// Get sessions endpoint url
let sessionsUrl = this.getEndpointUrl('sessions', ServerAction.OCPI_EMSP_GET_SESSIONS);
- const momentFrom = moment().utc().subtract(2, 'days').startOf('day');
+ let momentFrom: Moment;
+ if (partial) {
+ // Last 2 days by default
+ momentFrom = moment().utc().subtract(2, 'days').startOf('day');
+ } else {
+ // Last 2 weeks by default
+ momentFrom = moment().utc().subtract(2, 'weeks').startOf('day');
+ }
sessionsUrl = `${sessionsUrl}?date_from=${momentFrom.format()}&limit=10`;
let nextResult = true;
do {
@@ -326,7 +333,7 @@ export default class EmspOCPIClient extends OCPIClient {
return result;
}
- public async pullCdrs(): Promise<OCPIResult> {
+ public async pullCdrs(partial = false): Promise<OCPIResult> {
// Result
const result: OCPIResult = {
success: 0,
@@ -338,7 +345,14 @@ export default class EmspOCPIClient extends OCPIClient {
const startTime = new Date().getTime();
// Get cdrs endpoint url
let cdrsUrl = this.getEndpointUrl('cdrs', ServerAction.OCPI_EMSP_GET_CDRS);
- const momentFrom = moment().utc().subtract(2, 'days').startOf('day');
+ let momentFrom: Moment;
+ if (partial) {
+ // Last 2 days by default
+ momentFrom = moment().utc().subtract(2, 'days').startOf('day');
+ } else {
+ // Last 2 weeks by default
+ momentFrom = moment().utc().subtract(2, 'weeks').startOf('day');
+ }
cdrsUrl = `${cdrsUrl}?date_from=${momentFrom.format()}&limit=10`;
let nextResult = true;
do {

MODIFY
src/scheduler/tasks/ocpi/OCPICheckCdrsTask.ts
src/scheduler/tasks/ocpi/OCPICheckCdrsTask.ts
@@ -65,6 +65,7 @@ export default class OCPICheckCdrsTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getCpoOcpiClient(tenant, ocpiEndpoint);
+ // Check CDRs
const result = await ocpiClient.checkCdrs();
await Logging.logInfo({
tenantID: tenant.id,

MODIFY
src/scheduler/tasks/ocpi/OCPICheckLocationsTask.ts
src/scheduler/tasks/ocpi/OCPICheckLocationsTask.ts
@@ -65,6 +65,7 @@ export default class OCPICheckLocationsTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getCpoOcpiClient(tenant, ocpiEndpoint);
+ // Check Locations
const result = await ocpiClient.checkLocations();
await Logging.logInfo({
tenantID: tenant.id,

MODIFY
src/scheduler/tasks/ocpi/OCPICheckSessionsTask.ts
src/scheduler/tasks/ocpi/OCPICheckSessionsTask.ts
@@ -65,6 +65,7 @@ export default class OCPICheckSessionsTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getCpoOcpiClient(tenant, ocpiEndpoint);
+ // Check Sessions
const result = await ocpiClient.checkSessions();
await Logging.logInfo({
tenantID: tenant.id,

MODIFY
src/scheduler/tasks/ocpi/OCPIPullCdrsTask.ts
src/scheduler/tasks/ocpi/OCPIPullCdrsTask.ts
@@ -66,8 +66,8 @@ export default class OCPIPullCdrsTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getEmspOcpiClient(tenant, ocpiEndpoint);
- // Send EVSE statuses
- const result = await ocpiClient.pullCdrs();
+ // Pull CDRs
+ const result = await ocpiClient.pullCdrs(true);
await Logging.logInfo({
tenantID: tenant.id,
action: ServerAction.OCPI_EMSP_GET_CDRS,

MODIFY
src/scheduler/tasks/ocpi/OCPIPullLocationsTask.ts
src/scheduler/tasks/ocpi/OCPIPullLocationsTask.ts
@@ -65,7 +65,7 @@ export default class OCPIPullLocationsTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getEmspOcpiClient(tenant, ocpiEndpoint);
- // Send EVSE statuses
+ // Pull Locations
const result = await ocpiClient.pullLocations(config.partial);
await Logging.logInfo({
tenantID: tenant.id,

MODIFY
src/scheduler/tasks/ocpi/OCPIPullSessionsTask.ts
src/scheduler/tasks/ocpi/OCPIPullSessionsTask.ts
@@ -65,8 +65,8 @@ export default class OCPIPullSessionsTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getEmspOcpiClient(tenant, ocpiEndpoint);
- // Send EVSE statuses
- const result = await ocpiClient.pullSessions();
+ // Pull Sessions
+ const result = await ocpiClient.pullSessions(true);
await Logging.logInfo({
tenantID: tenant.id,
module: MODULE_NAME, method: 'processOCPIEndpoint',

MODIFY
src/scheduler/tasks/ocpi/OCPIPullTokensTask.ts
src/scheduler/tasks/ocpi/OCPIPullTokensTask.ts
@@ -65,7 +65,7 @@ export default class OCPIPullTokensTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getCpoOcpiClient(tenant, ocpiEndpoint);
- // Send EVSE statuses
+ // Pull Tokens
const result = await ocpiClient.pullTokens(config.partial);
await Logging.logInfo({
tenantID: tenant.id,

MODIFY
src/scheduler/tasks/ocpi/OCPIPushEVSEStatusesTask.ts
src/scheduler/tasks/ocpi/OCPIPushEVSEStatusesTask.ts
@@ -65,7 +65,7 @@ export default class OCPIPushEVSEStatusesTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getCpoOcpiClient(tenant, ocpiEndpoint);
- // Send EVSE statuses
+ // Push EVSE statuses
const sendResult = await ocpiClient.pushChargingStationStatuses(config.partial);
await Logging.logInfo({
tenantID: tenant.id,

MODIFY
src/scheduler/tasks/ocpi/OCPIPushTokensTask.ts
src/scheduler/tasks/ocpi/OCPIPushTokensTask.ts
@@ -65,7 +65,7 @@ export default class OCPIPushTokensTask extends TenantSchedulerTask {
});
// Build OCPI Client
const ocpiClient = await OCPIClientFactory.getEmspOcpiClient(tenant, ocpiEndpoint);
- // Push the Tokens
+ // Push Tokens
const result = await ocpiClient.pushTokens(config.partial);
await Logging.logInfo({
tenantID: tenant.id,

Pull the last 2 weeks eMSP Cdrs/Sessions when triggered manually