From: Jérôme Benoit Date: Sat, 13 Jan 2024 23:14:01 +0000 (+0100) Subject: refactor: cleanup MikroORM entities X-Git-Tag: v1.2.32~13 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=a8599ae9ed113db82ee4857c7a660faca5ec7fb8;p=e-mobility-charging-stations-simulator.git refactor: cleanup MikroORM entities Signed-off-by: Jérôme Benoit --- diff --git a/src/types/index.ts b/src/types/index.ts index 600a4c0e..2ca7e8cc 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -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 index b5cc8027..00000000 --- a/src/types/orm/entities/PerformanceData.ts +++ /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 -} diff --git a/src/types/orm/entities/PerformanceRecord.ts b/src/types/orm/entities/PerformanceRecord.ts index a0ee77e7..dbe9ceec 100644 --- a/src/types/orm/entities/PerformanceRecord.ts +++ b/src/types/orm/entities/PerformanceRecord.ts @@ -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(this) + @Property() + performanceData!: PerformanceData[] }