refactor: update MikroORM entities definition
authorJérôme Benoit <jerome.benoit@sap.com>
Sat, 13 Jan 2024 22:10:14 +0000 (23:10 +0100)
committerJérôme Benoit <jerome.benoit@sap.com>
Sat, 13 Jan 2024 22:10:14 +0000 (23:10 +0100)
Signed-off-by: Jérôme Benoit <jerome.benoit@sap.com>
src/charging-station/ChargingStation.ts
src/types/orm/entities/PerformanceData.ts
src/types/orm/entities/PerformanceRecord.ts

index 6cfcd707d489f3e8e709247d377f240226c8e160..7534f66e72f38abd778d11397b42708a03ab0af3 100644 (file)
@@ -1763,7 +1763,8 @@ export class ChargingStation extends EventEmitter {
           })
           // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
           this.bootNotificationResponse.currentTime = convertToDate(
-            this.bootNotificationResponse.currentTime
+            // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
+            this.bootNotificationResponse?.currentTime
           )!
           if (!this.isRegistered()) {
             this.stationInfo?.registrationMaxRetries !== -1 && ++registrationRetryCount
index 28f2b34665d1b296d591336d3ed8605faeed6dda..b5cc80271549cdbbb8acbbeb6e9f9cb8d9bca425 100644 (file)
@@ -1,41 +1,51 @@
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
 import { Entity, ManyToOne, PrimaryKey, Property } from '@mikro-orm/core'
 
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
 import { PerformanceRecord } from './PerformanceRecord.js'
 
 @Entity()
 export class PerformanceData {
-  // @PrimaryKey()
-  //   pk!: number
-  // @Property()
-  //   commandName!: string
-  // @Property()
-  //   countRequest!: number
-  // @Property()
-  //   countResponse!: number
-  // @Property()
-  //   countError!: number
-  // @Property()
-  //   countTimeMeasurement!: number
-  // @Property()
-  //   timeMeasurementSeries!: 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
+  @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 36db5c5bc1b2f19235afac093074c3db4aabe310..a0ee77e756f4f2d9e628c002963ec16c8c8588fc 100644 (file)
@@ -1,21 +1,24 @@
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
 import { Collection, Entity, OneToMany, PrimaryKey, Property } from '@mikro-orm/core'
 
-// eslint-disable-next-line @typescript-eslint/no-unused-vars
-import type { PerformanceData } from './PerformanceData.js'
+import { PerformanceData } from './PerformanceData.js'
 
 @Entity()
 export class PerformanceRecord {
-  // @PrimaryKey()
-  //   pk!: number
-  // @Property()
-  //   id!: string
-  // @Property()
-  //   URI!: string
-  // @Property()
-  //   createdAt!: Date
-  // @Property()
-  //   updatedAt?: Date
-  // @OneToMany('PerformanceData', 'performanceRecord')
-  //   performanceData? = new Collection<PerformanceData>(this)
+  @PrimaryKey()
+    id!: string
+
+  @Property()
+    name!: string
+
+  @Property()
+    uri!: string
+
+  @Property()
+    createdAt!: Date
+
+  @Property()
+    updatedAt?: Date
+
+  @OneToMany(() => PerformanceData, performanceData => performanceData.performanceRecord)
+    performanceData? = new Collection<PerformanceData>(this)
 }