refactor: cleanup MikroORM entities
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 13 Jan 2024 23:14:01 +0000 (00:14 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 13 Jan 2024 23:14:01 +0000 (00:14 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/types/index.ts
src/types/orm/entities/PerformanceData.ts [deleted file]
src/types/orm/entities/PerformanceRecord.ts

index 600a4c0eb26f5b066edc86968b37f03c4f24b633..2ca7e8cce450e93a144739943518e7948009cd10 100644 (file)
@@ -259,7 +259,6 @@ export type {
 } from './ocpp/2.0/Responses.js'
 export { OCPP20OptionalVariableName } from './ocpp/2.0/Variables.js'
 export { OCPPVersion } from './ocpp/OCPPVersion.js'
-export { PerformanceData } from './orm/entities/PerformanceData.js'
 export { PerformanceRecord } from './orm/entities/PerformanceRecord.js'
 export type { Statistics, TimestampedData } from './Statistics.js'
 export {
diff --git a/src/types/orm/entities/PerformanceData.ts b/src/types/orm/entities/PerformanceData.ts
deleted file mode 100644 (file)
index b5cc802..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
-
-import { PerformanceRecord } from './PerformanceRecord.js'
-
-@Entity()
-export class PerformanceData {
-  @PrimaryKey()
-    commandName!: string
-
-  @Property()
-    requestCount!: number
-
-  @Property()
-    responseCount!: number
-
-  @Property()
-    errorCount!: number
-
-  @Property()
-    timeMeasurementCount!: number
-
-  @Property()
-    measurementTimeSeries!: number[]
-
-  @Property()
-    currentTimeMeasurement!: number
-
-  @Property()
-    minTimeMeasurement!: number
-
-  @Property()
-    maxTimeMeasurement!: number
-
-  @Property()
-    totalTimeMeasurement!: number
-
-  @Property()
-    avgTimeMeasurement!: number
-
-  @Property()
-    medTimeMeasurement!: number
-
-  @Property()
-    ninetyFiveThPercentileTimeMeasurement!: number
-
-  @Property()
-    stdDevTimeMeasurement!: number
-
-  @ManyToOne(() => PerformanceRecord)
-    performanceRecord!: PerformanceRecord
-}
index a0ee77e756f4f2d9e628c002963ec16c8c8588fc..dbe9ceeca87e4160e66f73c2c5ccced5edf0ab4e 100644 (file)
@@ -1,6 +1,24 @@
-import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
+import { Entity, PrimaryKey, Property } from '@mikro-orm/core'
 
-import { PerformanceData } from './PerformanceData.js'
+interface PerformanceData {
+  name: string
+  requestCount: number
+  responseCount: number
+  errorCount: number
+  timeMeasurementCount: number
+  measurementTimeSeries: Array<{
+    timestamp: number
+    value: number
+  }>
+  currentTimeMeasurement: number
+  minTimeMeasurement: number
+  maxTimeMeasurement: number
+  totalTimeMeasurement: number
+  avgTimeMeasurement: number
+  medTimeMeasurement: number
+  ninetyFiveThPercentileTimeMeasurement: number
+  stdDevTimeMeasurement: number
+}
 
 @Entity()
 export class PerformanceRecord {
@@ -19,6 +37,6 @@ export class PerformanceRecord {
   @Property()
     updatedAt?: Date
 
-  @OneToMany(() => PerformanceData, performanceData => performanceData.performanceRecord)
-    performanceData? = new Collection<PerformanceData>(this)
+  @Property()
+    performanceData!: PerformanceData[]
 }