Get OCPI eMSP Tags with createdOn in addition to lastChangedOn
MODIFY
src/storage/mongodb/TagStorage.ts
src/storage/mongodb/TagStorage.ts
@@ -346,11 +346,22 @@ export default class TagStorage {
filters.active = params.active;
}
// Dates
- if (params.dateFrom && moment(params.dateFrom).isValid()) {
- filters.lastChangedOn = { $gte: new Date(params.dateFrom) };
+ if ((params.dateFrom && moment(params.dateFrom).isValid()) ||
+ (params.dateTo && moment(params.dateTo).isValid())) {
+ const lastChangedOn: any = {};
+ const createdOn: any = {};
+ if (params.dateFrom) {
+ lastChangedOn.$gte = Utils.convertToDate(params.dateFrom);
+ createdOn.$gte = Utils.convertToDate(params.dateFrom);
+ }
+ if (params.dateTo) {
+ lastChangedOn.$lte = Utils.convertToDate(params.dateTo);
+ createdOn.$lte = Utils.convertToDate(params.dateTo);
}
- if (params.dateTo && moment(params.dateTo).isValid()) {
- filters.lastChangedOn = { $lte: new Date(params.dateTo) };
+ filters.$or = [
+ { lastChangedOn },
+ { createdOn },
+ ];
}
if (!Utils.isEmptyJSon(filters)) {
aggregation.push({ $match: filters });

Get OCPI eMSP Tags with createdOn in addition to lastChangedOn