repositories
/
e-mobility-charging-stations-simulator.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix: fix performance records duplication
[e-mobility-charging-stations-simulator.git]
/
src
/
performance
/
storage
/
MikroOrmStorage.ts
diff --git
a/src/performance/storage/MikroOrmStorage.ts
b/src/performance/storage/MikroOrmStorage.ts
index 021bc28b078a658e7e4191d9fae13a2a45c31a84..d1b84b8577d6bd267cf709cbc4cfd0880ceaea88 100644
(file)
--- a/
src/performance/storage/MikroOrmStorage.ts
+++ b/
src/performance/storage/MikroOrmStorage.ts
@@
-1,21
+1,27
@@
// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
// Copyright Jerome Benoit. 2021-2023. All Rights Reserved.
-import { Configuration, Connection, IDatabaseDriver, MikroORM, Options } from '@mikro-orm/core';
+import {
+ Configuration,
+ Connection,
+ type IDatabaseDriver,
+ MikroORM,
+ type Options,
+} from '@mikro-orm/core';
import { TsMorphMetadataProvider } from '@mikro-orm/reflection';
import { TsMorphMetadataProvider } from '@mikro-orm/reflection';
+import { Storage } from './Storage';
import {
import {
- type MikroO
RMDB
Type,
+ type MikroO
rmDb
Type,
PerformanceData,
PerformanceRecord,
type Statistics,
StorageType,
} from '../../types';
PerformanceData,
PerformanceRecord,
type Statistics,
StorageType,
} from '../../types';
-import { Constants } from '../../utils/Constants';
-import { Storage } from '../internal';
+import { Constants } from '../../utils';
export class MikroOrmStorage extends Storage {
private storageType: StorageType;
export class MikroOrmStorage extends Storage {
private storageType: StorageType;
- private orm
!: MikroORM | null
;
+ private orm
?: MikroORM
;
constructor(storageUri: string, logPrefix: string, storageType: StorageType) {
super(storageUri, logPrefix);
constructor(storageUri: string, logPrefix: string, storageType: StorageType) {
super(storageUri, logPrefix);
@@
-23,6
+29,7
@@
export class MikroOrmStorage extends Storage {
this.dbName = this.getDBName();
}
this.dbName = this.getDBName();
}
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
public async storePerformanceStatistics(performanceStatistics: Statistics): Promise<void> {
try {
const performanceRecord = new PerformanceRecord();
public async storePerformanceStatistics(performanceStatistics: Statistics): Promise<void> {
try {
const performanceRecord = new PerformanceRecord();
@@
-46,7
+53,7
@@
export class MikroOrmStorage extends Storage {
try {
if (this?.orm) {
await this.orm.close();
try {
if (this?.orm) {
await this.orm.close();
-
this.orm = null
;
+
delete this?.orm
;
}
} catch (error) {
this.handleDBError(this.storageType, error as Error);
}
} catch (error) {
this.handleDBError(this.storageType, error as Error);
@@
-69,7
+76,7
@@
export class MikroOrmStorage extends Storage {
return {
metadataProvider: TsMorphMetadataProvider,
entities: [PerformanceRecord, PerformanceData],
return {
metadataProvider: TsMorphMetadataProvider,
entities: [PerformanceRecord, PerformanceData],
- type: this.storageType as MikroO
RMDB
Type,
+ type: this.storageType as MikroO
rmDb
Type,
clientUrl: this.getClientUrl(),
};
}
clientUrl: this.getClientUrl(),
};
}