+import { CircularBuffer } from 'mnemonist'
+
import type { ChargingStation } from '../charging-station/index.js'
import {
type ChargingStationData,
type ChargingStationWorkerMessage,
ChargingStationWorkerMessageEvents,
- type Statistics
+ type Statistics,
+ type TimestampedData
} from '../types/index.js'
import {
buildChargingStationAutomaticTransactionGeneratorConfiguration,
export const buildPerformanceStatisticsMessage = (
statistics: Statistics
): ChargingStationWorkerMessage<Statistics> => {
+ const statisticsData = [...statistics.statisticsData].map(([key, value]) => {
+ if (value.measurementTimeSeries instanceof CircularBuffer) {
+ value.measurementTimeSeries = value.measurementTimeSeries.toArray() as TimestampedData[]
+ }
+ return [key, value]
+ })
return {
event: ChargingStationWorkerMessageEvents.performanceStatistics,
- data: statistics
+ data: {
+ id: statistics.id,
+ name: statistics.name,
+ uri: statistics.uri,
+ createdAt: statistics.createdAt,
+ updatedAt: statistics.updatedAt,
+ statisticsData
+ }
}
}