Removed deprecated endpoint data + Optimized getting charger list from DB
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -1146,7 +1146,8 @@ export default class OCPPService {
private async notifyStatusNotification(tenantID: string, chargingStation: ChargingStation, statusNotification: OCPPStatusNotificationRequestExtended) {
// Faulted?
- if (statusNotification.status !== ChargePointStatus.FINISHING && // TODO: To remove after fix of ABB bug having Finishing status with an Error Code to avoid spamming Admins
+ if (statusNotification.status !== ChargePointStatus.AVAILABLE &&
+ statusNotification.status !== ChargePointStatus.FINISHING && // TODO: To remove after fix of ABB bug having Finishing status with an Error Code to avoid spamming Admins
statusNotification.errorCode !== ChargePointErrorCode.NO_ERROR) {
// Log
Logging.logError({

MODIFY
src/server/rest/CentralRestServerService.ts
src/server/rest/CentralRestServerService.ts
@@ -145,8 +145,6 @@ class RequestMapper {
[ServerAction.SITE_AREAS]: SiteAreaService.handleGetSiteAreas.bind(this),
[ServerAction.SITE_AREA]: SiteAreaService.handleGetSiteArea.bind(this),
[ServerAction.SITE_AREA_CONSUMPTION]: SiteAreaService.handleGetSiteAreaConsumption.bind(this),
- // TODO: To remove the 'SITE_IMAGE' when new version of Mobile App will be released (> V1.3.22)
- [ServerAction.SITE_IMAGE]: SiteService.handleGetSiteImage.bind(this),
[ServerAction.USERS]: UserService.handleGetUsers.bind(this),
[ServerAction.USER_SITES]: UserService.handleGetSites.bind(this),
[ServerAction.USERS_IN_ERROR]: UserService.handleGetUsersInError.bind(this),

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -809,7 +809,6 @@ export default class ChargingStationService {
});
}
}
- const ocppParams: OCPPParams[] = [];
// Set the attachment name
res.attachment('exported-ocpp-params.csv');
let writeHeader = true;
@@ -1266,9 +1265,8 @@ export default class ChargingStationService {
// Project fields
if (!projectFields) {
projectFields = [
- // TODO: To remove the 'lastHeartBeat' when new version of Mobile App will be released (> V1.3.22)
'id', 'inactive', 'connectorsStatus', 'connectorsConsumption', 'public', 'firmwareVersion', 'chargePointVendor', 'chargePointModel',
- 'ocppVersion', 'ocppProtocol', 'lastSeen', 'lastHeartBeat', 'firmwareUpdateStatus', 'coordinates', 'issuer', 'voltage',
+ 'ocppVersion', 'ocppProtocol', 'lastSeen', 'firmwareUpdateStatus', 'coordinates', 'issuer', 'voltage',
'siteAreaID', 'siteArea.id', 'siteArea.name', 'siteArea.siteID', 'siteArea.site.name', 'siteArea.address', 'maximumPower', 'powerLimitUnit',
'chargePointModel', 'chargePointSerialNumber', 'chargeBoxSerialNumber', 'connectors.connectorId', 'connectors.status', 'connectors.type', 'connectors.power', 'connectors.errorCode',
'connectors.currentTotalConsumptionWh', 'connectors.currentInstantWatts', 'connectors.currentStateOfCharge',

MODIFY
src/server/rest/v1/service/SiteService.ts
src/server/rest/v1/service/SiteService.ts
@@ -437,10 +437,6 @@ export default class SiteService {
// Filter
const filteredRequest = SiteSecurity.filterSiteImageRequest(req.query);
UtilsService.assertIdIsProvided(action, filteredRequest.ID, MODULE_NAME, 'handleGetSiteImage', req.user);
- // TODO: To remove when new version of Mobile App will be released (> V1.3.22)
- if (req.user) {
- filteredRequest.TenantID = req.user.tenantID;
- }
// Get the image
const siteImage = await SiteStorage.getSiteImage(filteredRequest.TenantID, filteredRequest.ID);
// Return

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -533,8 +533,7 @@ export default class TransactionService {
if (filteredRequest.LoadAllConsumptions) {
const consumptionsMDB = await ConsumptionStorage.getTransactionConsumptions(
req.user.tenantID, { transactionId: transaction.id }, Constants.DB_PARAMS_MAX_LIMIT, [
- // TODO: To remove the 'date' when new version of Mobile App will be released (> V1.3.22)
- 'date', 'startedAt', 'endedAt', 'cumulatedConsumptionWh', 'cumulatedConsumptionAmps', 'cumulatedAmount',
+ 'startedAt', 'endedAt', 'cumulatedConsumptionWh', 'cumulatedConsumptionAmps', 'cumulatedAmount',
'stateOfCharge', 'limitWatts', 'limitAmps',
'instantVoltsDC', 'instantVolts', 'instantVoltsL1', 'instantVoltsL2', 'instantVoltsL3',
'instantWattsDC', 'instantWatts', 'instantWattsL1', 'instantWattsL2', 'instantWattsL3',
@@ -545,8 +544,7 @@ export default class TransactionService {
} else {
consumptions = await ConsumptionStorage.getOptimizedTransactionConsumptions(
req.user.tenantID, { transactionId: transaction.id }, [
- // TODO: To remove the 'consumptions.date' when new version of Mobile App will be released (> V1.3.22)
- 'consumptions.date', 'consumptions.startedAt', 'consumptions.cumulatedConsumptionWh', 'consumptions.cumulatedConsumptionAmps', 'consumptions.cumulatedAmount',
+ 'consumptions.startedAt', 'consumptions.cumulatedConsumptionWh', 'consumptions.cumulatedConsumptionAmps', 'consumptions.cumulatedAmount',
'consumptions.stateOfCharge', 'consumptions.limitWatts', 'consumptions.limitAmps', 'consumptions.startedAt', 'consumptions.endedAt',
'consumptions.instantVoltsDC', 'consumptions.instantVolts', 'consumptions.instantVoltsL1', 'consumptions.instantVoltsL2', 'consumptions.instantVoltsL3',
'consumptions.instantWattsDC', 'consumptions.instantWatts', 'consumptions.instantWattsL1', 'consumptions.instantWattsL2', 'consumptions.instantWattsL3',

MODIFY
src/server/rest/v1/service/security/UtilsSecurity.ts
src/server/rest/v1/service/security/UtilsSecurity.ts
@@ -25,11 +25,6 @@ export default class UtilsSecurity {
}
static filterSort(request, filteredRequest): void {
- // Deprecated sorting?
- if (Utils.objectHasProperty(request, 'SortDirs')) {
- this.filterOldSort(request, filteredRequest);
- return;
- }
// Exist?
if (request.SortFields) {
// Sanitize
@@ -57,42 +52,6 @@ export default class UtilsSecurity {
}
}
- // TODO: To remove in the next mobile deployment > 1.3.22
- static filterOldSort(request, filteredRequest): void {
- // Exist?
- if (request.SortFields) {
- // Sanitize
- request.SortFields = sanitize(request.SortFields);
- request.SortDirs = sanitize(request.SortDirs);
- // Array?
- if (Array.isArray(request.SortFields) && request.SortFields.length > 0) {
- // Init
- filteredRequest.Sort = {};
- // Build
- for (let i = 0; i < request.SortFields.length; i++) {
- let sortField = request.SortFields[i];
- // Check field ID
- if (sortField === 'id') {
- // In MongoDB it's '_id'
- sortField = '_id';
- }
- // Set
- filteredRequest.Sort[sortField] = (request.SortDirs[i] === 'asc' ? 1 : -1);
- }
- } else {
- // Init
- filteredRequest.Sort = {};
- // Check field ID
- if (request.SortFields === 'id') {
- // In MongoDB it's '_id'
- request.SortFields = '_id';
- }
- // Set
- filteredRequest.Sort[request.SortFields] = (request.SortDirs === 'asc' ? 1 : -1);
- }
- }
- }
-
static filterSkipAndLimit(request: any, filteredRequest: any): void {
// Limit
UtilsSecurity.filterLimit(request, filteredRequest);

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -258,13 +258,14 @@ export default class ChargingStationStorage {
if (!Utils.isEmptyArray(params.siteAreaIDs)) {
filters.siteAreaID = { $in: params.siteAreaIDs.map((id) => Utils.convertToObjectID(id)) };
}
+ // Check Site ID
+ if (!Utils.isEmptyArray(params.siteIDs)) {
+ // TODO: Optimization: Assign SiteID to the charging station object
// Site Area
DatabaseUtils.pushSiteAreaLookupInAggregation({
tenantID, aggregation: aggregation, localField: 'siteAreaID', foreignField: '_id',
asField: 'siteArea', oneToOneCardinality: true
});
- // Check Site ID
- if (!Utils.isEmptyArray(params.siteIDs)) {
// Build filter
aggregation.push({
$match: {
@@ -305,8 +306,6 @@ export default class ChargingStationStorage {
if (!dbParams.sort) {
dbParams.sort = { _id: 1 };
}
- // Always add Connector ID
- dbParams.sort = { ...dbParams.sort, 'connectors.connectorId': 1 };
// Position coordinates
if (Utils.containsGPSCoordinates(params.locCoordinates)) {
// Override (can have only one sort)
@@ -328,6 +327,13 @@ export default class ChargingStationStorage {
tenantID, aggregation: aggregation, localField: 'connectors.userID', foreignField: '_id',
asField: 'connectors.user', oneToOneCardinality: true, objectIDFields: ['createdBy', 'lastChangedBy']
}, { sort: dbParams.sort });
+ // Site Area
+ if (Utils.isEmptyArray(params.siteIDs)) {
+ DatabaseUtils.pushSiteAreaLookupInAggregation({
+ tenantID, aggregation: aggregation, localField: 'siteAreaID', foreignField: '_id',
+ asField: 'siteArea', oneToOneCardinality: true
+ });
+ }
// Site
if (params.withSite && !params.withNoSiteArea) {
DatabaseUtils.pushSiteLookupInAggregation({
@@ -335,12 +341,6 @@ export default class ChargingStationStorage {
asField: 'siteArea.site', oneToOneCardinality: true
});
}
- // TODO: To remove the 'lastHeartBeat' when new version of Mobile App will be released (> V1.3.22)
- aggregation.push({
- '$addFields': {
- 'lastHeartBeat': '$lastSeen'
- }
- });
// Change ID
DatabaseUtils.pushRenameDatabaseID(aggregation);
// Convert siteID back to string after having queried the site
@@ -351,6 +351,15 @@ export default class ChargingStationStorage {
DatabaseUtils.pushConvertObjectIDToString(aggregation, 'siteAreaID');
// Project
DatabaseUtils.projectFields(aggregation, projectFields);
+ // Reorder connector ID
+ // TODO: To remove the 'if containsGPSCoordinates' when SiteID optimization will be implemented
+ if (!Utils.containsGPSCoordinates(params.locCoordinates)) {
+ // Always add Connector ID
+ dbParams.sort = { ...dbParams.sort, 'connectors.connectorId': 1 };
+ aggregation.push({
+ $sort: dbParams.sort
+ });
+ }
// Read DB
const chargingStationsMDB = await global.database.getCollection<ChargingStation>(tenantID, 'chargingstations')
.aggregate(aggregation, {

MODIFY
src/storage/mongodb/ConsumptionStorage.ts
src/storage/mongodb/ConsumptionStorage.ts
@@ -280,10 +280,6 @@ export default class ConsumptionStorage {
transactionId: Utils.convertToInt(params.transactionId)
}
});
- // TODO: To remove when new version of Mobile App will be released (> V1.3.22)
- aggregation.push({
- $addFields: { date: '$startedAt' }
- });
// Convert Object ID to string
DatabaseUtils.pushConvertObjectIDToString(aggregation, 'siteAreaID');
DatabaseUtils.pushConvertObjectIDToString(aggregation, 'siteID');
@@ -372,10 +368,6 @@ export default class ConsumptionStorage {
aggregation.push({
$addFields: { roundedInstantPower: { $round: [{ $divide: ['$instantWatts', 100] }] } }
});
- // TODO: To remove when new version of Mobile App will be released (> V1.3.22)
- aggregation.push({
- $addFields: { date: '$startedAt' }
- });
// Triming excess values
aggregation.push({
$group: {

Removed deprecated endpoint data + Optimized getting charger list from DB