Added 5 columns to the sessions / export csv
To specify the timezone and time of the charging station only
MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -35,7 +35,7 @@ import UserStorage from '../../../../storage/mongodb/UserStorage';
import UserToken from '../../../../types/UserToken';
import Utils from '../../../../utils/Utils';
import UtilsService from './UtilsService';
-import moment from 'moment';
+import moment from 'moment-timezone';
const MODULE_NAME = 'TransactionService';
@@ -848,7 +848,7 @@ export default class TransactionService {
let csv = '';
// Header
if (writeHeader) {
- csv = `ID${Constants.CSV_SEPARATOR}Charging Station${Constants.CSV_SEPARATOR}Connector${Constants.CSV_SEPARATOR}User ID${Constants.CSV_SEPARATOR}User${Constants.CSV_SEPARATOR}Start Date${Constants.CSV_SEPARATOR}Start Time${Constants.CSV_SEPARATOR}End Date${Constants.CSV_SEPARATOR}End Time${Constants.CSV_SEPARATOR}Total Consumption (kW.h)${Constants.CSV_SEPARATOR}Total Duration (Mins)${Constants.CSV_SEPARATOR}Total Inactivity (Mins)${Constants.CSV_SEPARATOR}Price${Constants.CSV_SEPARATOR}Price Unit\r\n`;
+ csv = `ID${Constants.CSV_SEPARATOR}Charging Station${Constants.CSV_SEPARATOR}Connector${Constants.CSV_SEPARATOR}User ID${Constants.CSV_SEPARATOR}User${Constants.CSV_SEPARATOR}Charging station timezone${Constants.CSV_SEPARATOR}Start Date${Constants.CSV_SEPARATOR}Start Time${Constants.CSV_SEPARATOR}End Date${Constants.CSV_SEPARATOR}End Time${Constants.CSV_SEPARATOR}Total Consumption (kW.h)${Constants.CSV_SEPARATOR}Total Duration (Mins)${Constants.CSV_SEPARATOR}Total Inactivity (Mins)${Constants.CSV_SEPARATOR}Price${Constants.CSV_SEPARATOR}Price Unit\r\n`;
}
// Content
for (const transaction of transactions) {
@@ -857,10 +857,11 @@ export default class TransactionService {
csv += `${transaction.connectorId}` + Constants.CSV_SEPARATOR;
csv += `${transaction.user ? Cypher.hash(transaction.user.id) : ''}` + Constants.CSV_SEPARATOR;
csv += `${transaction.user ? Utils.buildUserFullName(transaction.user, false) : ''}` + Constants.CSV_SEPARATOR;
- csv += `${moment(transaction.timestamp).format('YYYY-MM-DD')}` + Constants.CSV_SEPARATOR;
- csv += `${moment(transaction.timestamp).format('HH:mm:ss')}` + Constants.CSV_SEPARATOR;
- csv += `${transaction.stop ? `${moment(transaction.stop.timestamp).format('YYYY-MM-DD')}` : ''}` + Constants.CSV_SEPARATOR;
- csv += `${transaction.stop ? `${moment(transaction.stop.timestamp).format('HH:mm:ss')}` : ''}` + Constants.CSV_SEPARATOR;
+ csv += `${transaction.timezone}` + Constants.CSV_SEPARATOR;
+ csv += `${moment(transaction.timestamp).tz(transaction.timezone).format('YYYY-MM-DD')}` + Constants.CSV_SEPARATOR;
+ csv += `${moment(transaction.timestamp).tz(transaction.timezone).format('HH:mm:ss')}` + Constants.CSV_SEPARATOR;
+ csv += `${transaction.stop ? `${moment(transaction.stop.timestamp).tz(transaction.timezone).format('YYYY-MM-DD')}` : ''}` + Constants.CSV_SEPARATOR;
+ csv += `${transaction.stop ? `${moment(transaction.stop.timestamp).tz(transaction.timezone).format('HH:mm:ss')}` : ''}` + Constants.CSV_SEPARATOR;
csv += `${transaction.stop ? Math.round(transaction.stop.totalConsumptionWh ? transaction.stop.totalConsumptionWh / 1000 : 0) : ''}` + Constants.CSV_SEPARATOR;
csv += `${transaction.stop ? Math.round(transaction.stop.totalDurationSecs ? transaction.stop.totalDurationSecs / 60 : 0) : ''}` + Constants.CSV_SEPARATOR;
csv += `${transaction.stop ? Math.round(transaction.stop.totalInactivitySecs ? transaction.stop.totalInactivitySecs / 60 : 0) : ''}` + Constants.CSV_SEPARATOR;
@@ -965,7 +966,7 @@ export default class TransactionService {
projectFields = [
...projectFields,
'userID', 'user.id', 'user.name', 'user.firstName', 'user.email',
- 'stop.userID', 'stop.user.id', 'stop.user.name', 'stop.user.firstName', 'stop.user.email',
+ 'stop.userID', 'stop.user.id', 'stop.user.name', 'stop.user.firstName', 'stop.user.email'
];
}
}

Added 5 columns to the sessions / export csv
To specify the timezone and time of the charging station only