Removed circular deps
Removed unused indexes
MODIFY
src/storage/mongodb/MongoDBStorage.ts
src/storage/mongodb/MongoDBStorage.ts
@@ -111,10 +111,6 @@ export default class MongoDBStorage {
await this.handleIndexesInCollection(tenantID, 'importedusers', [
{ fields: { email: 1 }, options: { unique: true } }
]);
- await this.handleIndexesInCollection(tenantID, 'eulas');
- // Assets
- await this.handleIndexesInCollection(tenantID, 'assets', [
- ]);
// Invoices
await this.handleIndexesInCollection(tenantID, 'invoices', [
{ fields: { invoiceID: 1 }, options: { unique: true } },
@@ -145,7 +141,6 @@ export default class MongoDBStorage {
{ fields: { visualID: 1 }, options: { unique: true } },
{ fields: { issuer: 1, createdOn: 1 } },
{ fields: { createdOn: 1 } },
- { fields: { userID: 1, issuer: 1 } },
{ fields: { _id: 'text', description: 'text', visualID: 'text' } },
]);
// Tags Import

MODIFY
src/utils/NotificationHelper.ts
src/utils/NotificationHelper.ts
@@ -6,6 +6,7 @@ import Tenant from '../types/Tenant';
import Transaction from '../types/Transaction';
import User from '../types/User';
import Utils from './Utils';
+import moment from 'moment';
export default class NotificationHelper {
public static notifyStartTransaction(tenant: Tenant, transaction: Transaction, chargingStation: ChargingStation, user: User) {
@@ -107,7 +108,7 @@ export default class NotificationHelper {
connectorId: Utils.getConnectorLetterFromConnectorID(transaction.connectorId),
totalConsumption: i18nManager.formatNumber(Math.round(transaction.stop.totalConsumptionWh / 10) / 100),
totalDuration: Utils.transactionDurationToString(transaction),
- totalInactivity: Utils.transactionInactivityToString(transaction, user),
+ totalInactivity: NotificationHelper.transactionInactivityToString(transaction, user),
stateOfCharge: transaction.stop.stateOfCharge,
evseDashboardChargingStationURL: Utils.buildEvseTransactionURL(tenant.subdomain, transaction.id, '#history'),
evseDashboardURL: Utils.buildEvseURL(tenant.subdomain)
@@ -149,4 +150,17 @@ export default class NotificationHelper {
}
}
}
+
+ private static transactionInactivityToString(transaction: Transaction, user: User, i18nHourShort = 'h') {
+ const i18nManager = I18nManager.getInstanceForLocale(user ? user.locale : Constants.DEFAULT_LANGUAGE);
+ // Get total
+ const totalInactivitySecs = transaction.stop.totalInactivitySecs;
+ // None?
+ if (totalInactivitySecs === 0) {
+ return `0${i18nHourShort}00 (${i18nManager.formatPercentage(0)})`;
+ }
+ // Build the inactivity percentage
+ const totalInactivityPercent = i18nManager.formatPercentage(Math.round((totalInactivitySecs / transaction.stop.totalDurationSecs) * 100) / 100);
+ return moment.duration(totalInactivitySecs, 's').format(`h[${i18nHourShort}]mm`, { trim: false }) + ` (${totalInactivityPercent})`;
+ }
}

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -16,7 +16,6 @@ import Configuration from './Configuration';
import ConnectorStats from '../types/ConnectorStats';
import Constants from './Constants';
import { Decimal } from 'decimal.js';
-import I18nManager from './I18nManager';
import { Promise } from 'bluebird';
import QRCode from 'qrcode';
import { Request } from 'express';
@@ -1681,17 +1680,4 @@ export default class Utils {
}
return moment.duration(totalDurationSecs, 's').format('h[h]mm', { trim: false });
}
-
- public static transactionInactivityToString(transaction: Transaction, user: User, i18nHourShort = 'h') {
- const i18nManager = I18nManager.getInstanceForLocale(user ? user.locale : Constants.DEFAULT_LANGUAGE);
- // Get total
- const totalInactivitySecs = transaction.stop.totalInactivitySecs;
- // None?
- if (totalInactivitySecs === 0) {
- return `0${i18nHourShort}00 (${i18nManager.formatPercentage(0)})`;
- }
- // Build the inactivity percentage
- const totalInactivityPercent = i18nManager.formatPercentage(Math.round((totalInactivitySecs / transaction.stop.totalDurationSecs) * 100) / 100);
- return moment.duration(totalInactivitySecs, 's').format(`h[${i18nHourShort}]mm`, { trim: false }) + ` (${totalInactivityPercent})`;
- }
}

Removed circular deps
Removed unused indexes