From: Jérôme Benoit Date: Sat, 13 Jan 2024 22:10:14 +0000 (+0100) Subject: refactor: update MikroORM entities definition X-Git-Tag: v1.2.32~15 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=43be4c0834fe806a68f99036805779f29058d74e;p=e-mobility-charging-stations-simulator.git refactor: update MikroORM entities definition Signed-off-by: Jérôme Benoit --- diff --git a/src/charging-station/ChargingStation.ts b/src/charging-station/ChargingStation.ts index 6cfcd707..7534f66e 100644 --- a/src/charging-station/ChargingStation.ts +++ b/src/charging-station/ChargingStation.ts @@ -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 diff --git a/src/types/orm/entities/PerformanceData.ts b/src/types/orm/entities/PerformanceData.ts index 28f2b346..b5cc8027 100644 --- a/src/types/orm/entities/PerformanceData.ts +++ b/src/types/orm/entities/PerformanceData.ts @@ -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 } diff --git a/src/types/orm/entities/PerformanceRecord.ts b/src/types/orm/entities/PerformanceRecord.ts index 36db5c5b..a0ee77e7 100644 --- a/src/types/orm/entities/PerformanceRecord.ts +++ b/src/types/orm/entities/PerformanceRecord.ts @@ -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(this) + @PrimaryKey() + id!: string + + @Property() + name!: string + + @Property() + uri!: string + + @Property() + createdAt!: Date + + @Property() + updatedAt?: Date + + @OneToMany(() => PerformanceData, performanceData => performanceData.performanceRecord) + performanceData? = new Collection(this) }