Display footer stats for current charging sessions
MODIFY
src/assets/server/rest/v1/schemas/transaction/transactions-get.json
src/assets/server/rest/v1/schemas/transaction/transactions-get.json
"Statistics": {
"type": "string",
"sanitize": "mongo",
- "enum": ["refund", "history"]
+ "enum": ["refund", "history", "ongoing"]
},
"ReportIDs": {
"$ref": "common.json#/definitions/ids"

MODIFY
src/storage/mongodb/TransactionStorage.ts
src/storage/mongodb/TransactionStorage.ts
@@ -273,7 +273,7 @@ export default class TransactionStorage {
endDateTime?: Date; stop?: any; minimalPrice?: boolean; reportIDs?: string[]; tagIDs?: string[]; inactivityStatus?: string[];
ocpiSessionID?: string; ocpiAuthorizationID?: string; ocpiSessionDateFrom?: Date; ocpiSessionDateTo?: Date; ocpiCdrDateFrom?: Date; ocpiCdrDateTo?: Date;
ocpiSessionChecked?: boolean; ocpiCdrChecked?: boolean; oicpSessionID?: string;
- statistics?: 'refund' | 'history'; refundStatus?: string[]; withTag?: boolean; hasUserID?: boolean;
+ statistics?: 'refund' | 'history' | 'ongoing'; refundStatus?: string[]; withTag?: boolean; hasUserID?: boolean;
},
dbParams: DbParams, projectFields?: string[]):
Promise<{
@@ -480,6 +480,21 @@ export default class TransactionStorage {
}
};
break;
+ case 'ongoing': // For ongoing case
+ statsQuery = {
+ $group: {
+ _id: null,
+ firstTimestamp: { $min: '$timestamp' },
+ lastTimestamp: { $max: '$timestamp' },
+ totalConsumptionWattHours: { $sum: '$currentTotalConsumptionWh' },
+ totalDurationSecs: { $sum: '$currentTotalDurationSecs' },
+ totalPrice: { $sum: '$currentCumulatedPrice' },
+ totalInactivitySecs: { $sum: '$currentTotalInactivitySecs' },
+ currency: { $addToSet: '$priceUnit' },
+ count: { $sum: 1 }
+ }
+ };
+ break;
case 'refund': // For refund case
statsQuery = {
$group: {
@@ -515,6 +530,7 @@ export default class TransactionStorage {
if (!transactionCountMDB) {
switch (params.statistics) {
case 'history':
+ case 'ongoing':
transactionCountMDB = {
totalConsumptionWattHours: 0,
totalDurationSecs: 0,

MODIFY
src/types/requests/HttpTransactionRequest.ts
src/types/requests/HttpTransactionRequest.ts
@@ -37,7 +37,7 @@ export interface HttpTransactionsRequest extends HttpDatabaseRequest {
RefundStatus?: string;
InactivityStatus?: InactivityStatus;
MinimalPrice?: boolean;
- Statistics?: 'refund' | 'history';
+ Statistics?: 'refund' | 'history' | 'ongoing';
ReportIDs?: string;
Status?: 'completed' | 'active';
}

Display footer stats for current charging sessions