From a8599ae9ed113db82ee4857c7a660faca5ec7fb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Sun, 14 Jan 2024 00:14:01 +0100 Subject: [PATCH] refactor: cleanup MikroORM entities MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/types/index.ts | 1 - src/types/orm/entities/PerformanceData.ts | 51 --------------------- src/types/orm/entities/PerformanceRecord.ts | 26 +++++++++-- 3 files changed, 22 insertions(+), 56 deletions(-) delete mode 100644 src/types/orm/entities/PerformanceData.ts 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[] } -- 2.34.1