Fixed cannot see User in Charging Station's connector when charging
MODIFY
src/assets/server/rest/v1/schemas/chargingstation/chargingstations-get.json
src/assets/server/rest/v1/schemas/chargingstation/chargingstations-get.json
"type": "boolean",
"sanitize": "mongo"
},
+ "WithUser": {
+ "type": "boolean",
+ "sanitize": "mongo"
+ },
"SiteAreaID": {
"$ref": "common#/definitions/ids"
},

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1488,6 +1488,7 @@ export default class ChargingStationService {
withNoSiteArea: filteredRequest.WithNoSiteArea,
withSite: filteredRequest.WithSite,
withSiteArea: filteredRequest.WithSiteArea,
+ withUser: filteredRequest.WithUser,
chargingStationIDs: filteredRequest.ChargingStationID ? filteredRequest.ChargingStationID.split('|') : null,
connectorStatuses: filteredRequest.ConnectorStatus ? filteredRequest.ConnectorStatus.split('|') : null,
connectorTypes: filteredRequest.ConnectorType ? filteredRequest.ConnectorType.split('|') : null,

MODIFY
src/storage/mongodb/ChargingStationStorage.ts
src/storage/mongodb/ChargingStationStorage.ts
@@ -147,7 +147,7 @@ export default class ChargingStationStorage {
public static async getChargingStations(tenant: Tenant,
params: {
search?: string; chargingStationIDs?: string[]; chargingStationSerialNumbers?: string[]; siteAreaIDs?: string[]; withNoSiteArea?: boolean;
- connectorStatuses?: string[]; connectorTypes?: string[]; statusChangedBefore?: Date; withSiteArea?: boolean;
+ connectorStatuses?: string[]; connectorTypes?: string[]; statusChangedBefore?: Date; withSiteArea?: boolean; withUser?: boolean;
ocpiEvseUid?: string; ocpiEvseID?: string; ocpiLocationID?: string; oicpEvseID?: string;
siteIDs?: string[]; companyIDs?: string[]; withSite?: boolean; includeDeleted?: boolean; offlineSince?: Date; issuer?: boolean;
locCoordinates?: number[]; locMaxDistanceMeters?: number; public?: boolean;
@@ -340,10 +340,12 @@ export default class ChargingStationStorage {
$limit: dbParams.limit
});
// Users on connectors
+ if (params.withUser) {
DatabaseUtils.pushArrayLookupInAggregation('connectors', DatabaseUtils.pushUserLookupInAggregation.bind(this), {
tenantID: tenant.id, aggregation: aggregation, localField: 'connectors.currentUserID', foreignField: '_id',
asField: 'connectors.user', oneToOneCardinality: true, objectIDFields: ['createdBy', 'lastChangedBy']
}, { sort: dbParams.sort });
+ }
// Site Area
if (params.withSiteArea) {
DatabaseUtils.pushSiteAreaLookupInAggregation({

Fixed cannot see User in Charging Station's connector when charging