From 3dee41f9e72b9b36d3fa5fefa28eb942ae71c423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Henriot?= Date: Wed, 16 Oct 2024 13:22:15 +0200 Subject: [PATCH 1/2] feat: migrate originDestination connectionPenalty to netzgrafixDto --- src/app/data-structures/business.data.structures.ts | 10 ++++++++++ src/app/sample-netzgrafik/netzgrafik.default.ts | 5 +++++ src/app/utils/data-migration.ts | 5 +++++ .../editor-tools-view.component.ts | 6 +++--- .../netzgrafik.unit.test.reconnec.trainrunsectionst.ts | 5 +++++ .../netzgrafik.unit.testing.od.matrix.ts | 5 +++++ .../netzgrafik.unit.testing.transition.ts | 5 +++++ src/integration-testing/netzgrafik.unit.testing.ts | 5 +++++ 8 files changed, 43 insertions(+), 3 deletions(-) diff --git a/src/app/data-structures/business.data.structures.ts b/src/app/data-structures/business.data.structures.ts index d84f4d9b..c7e72141 100644 --- a/src/app/data-structures/business.data.structures.ts +++ b/src/app/data-structures/business.data.structures.ts @@ -252,6 +252,15 @@ export interface Haltezeit { no_halt: boolean; // no halt per default } +export interface OriginDestinationSettingsDto { + // TODO: we may want a UI to display/edit this. + connectionPenalty: number; // the cost to add for each connection, in minutes +} + +export interface AnalyticsSettingsDto { + originDestinationSettings: OriginDestinationSettingsDto; +} + /** * Groups Meta data in exported JSON / internal data structure (global properties for a project) */ @@ -260,6 +269,7 @@ export interface MetadataDto { trainrunFrequencies: TrainrunFrequency[]; trainrunTimeCategories: TrainrunTimeCategory[]; netzgrafikColors: NetzgrafikColorDto[]; + analyticsSettings: AnalyticsSettingsDto; } /** diff --git a/src/app/sample-netzgrafik/netzgrafik.default.ts b/src/app/sample-netzgrafik/netzgrafik.default.ts index bc6707d2..9c883ab7 100644 --- a/src/app/sample-netzgrafik/netzgrafik.default.ts +++ b/src/app/sample-netzgrafik/netzgrafik.default.ts @@ -205,6 +205,11 @@ export class NetzgrafikDefault { trainruns: [], resources: [], metadata: { + analyticsSettings: { + originDestinationSettings: { + connectionPenalty: 5, + } + }, trainrunCategories: [ { id: 0, diff --git a/src/app/utils/data-migration.ts b/src/app/utils/data-migration.ts index ab46188e..87a21599 100644 --- a/src/app/utils/data-migration.ts +++ b/src/app/utils/data-migration.ts @@ -80,6 +80,11 @@ export class DataMigration { NetzgrafikDefault.getDefaultNetzgrafik().metadata.netzgrafikColors; } + if (netzgrafikDto.metadata.analyticsSettings === undefined) { + netzgrafikDto.metadata.analyticsSettings = + NetzgrafikDefault.getDefaultNetzgrafik().metadata.analyticsSettings; + } + if (netzgrafikDto.freeFloatingTexts === undefined) { netzgrafikDto.freeFloatingTexts = NetzgrafikDefault.getDefaultNetzgrafik().freeFloatingTexts; diff --git a/src/app/view/editor-tools-view-component/editor-tools-view.component.ts b/src/app/view/editor-tools-view-component/editor-tools-view.component.ts index 00795a35..64f41965 100644 --- a/src/app/view/editor-tools-view-component/editor-tools-view.component.ts +++ b/src/app/view/editor-tools-view-component/editor-tools-view.component.ts @@ -500,9 +500,6 @@ export class EditorToolsViewComponent { // Split trainruns are not supported at the moment: // https://github.com/SchweizerischeBundesbahnen/netzgrafik-editor-frontend/issues/285 private convertToOriginDestinationCSV(): string { - // The cost to add for each connection. - // TODO: this may belong to the grafix metadata. - const connectionPenalty = 5; // Duration of the schedule to consider (in minutes). // TODO: ideally this would be 24 hours, but performance is a concern. const timeLimit = 10*60; @@ -514,6 +511,9 @@ export class EditorToolsViewComponent { headers.push($localize`:@@app.view.editor-side-view.editor-tools-view-component.connections:Connections`); headers.push($localize`:@@app.view.editor-side-view.editor-tools-view-component.totalCost:Total cost`); + const metadata = this.dataService.getNetzgrafikDto().metadata; + // The cost to add for each connection. + const connectionPenalty = metadata.analyticsSettings.originDestinationSettings.connectionPenalty; const nodes = this.nodeService.getNodes(); const selectedNodes = this.nodeService.getSelectedNodes(); const odNodes = selectedNodes.length > 0 ? selectedNodes : this.nodeService.getVisibleNodes(); diff --git a/src/integration-testing/netzgrafik.unit.test.reconnec.trainrunsectionst.ts b/src/integration-testing/netzgrafik.unit.test.reconnec.trainrunsectionst.ts index 457b1bac..bda20da2 100644 --- a/src/integration-testing/netzgrafik.unit.test.reconnec.trainrunsectionst.ts +++ b/src/integration-testing/netzgrafik.unit.test.reconnec.trainrunsectionst.ts @@ -696,6 +696,11 @@ export class NetzgrafikUnitTestingReconnectTrainrunSection { }, ], metadata: { + analyticsSettings: { + originDestinationSettings: { + connectionPenalty: 5, + } + }, trainrunCategories: [ { id: 0, diff --git a/src/integration-testing/netzgrafik.unit.testing.od.matrix.ts b/src/integration-testing/netzgrafik.unit.testing.od.matrix.ts index 6ed8ca06..b8a3f98c 100644 --- a/src/integration-testing/netzgrafik.unit.testing.od.matrix.ts +++ b/src/integration-testing/netzgrafik.unit.testing.od.matrix.ts @@ -950,6 +950,11 @@ export class NetzgrafikUnitTestingOdMatrix { } ], "metadata": { + "analyticsSettings": { + "originDestinationSettings": { + "connectionPenalty": 5, + } + }, "trainrunCategories": [ { "id": 0, diff --git a/src/integration-testing/netzgrafik.unit.testing.transition.ts b/src/integration-testing/netzgrafik.unit.testing.transition.ts index 43b14e33..77bf831e 100644 --- a/src/integration-testing/netzgrafik.unit.testing.transition.ts +++ b/src/integration-testing/netzgrafik.unit.testing.transition.ts @@ -1126,6 +1126,11 @@ export class NetzgrafikUnitTestingTransition { }, ], metadata: { + analyticsSettings: { + originDestinationSettings: { + connectionPenalty: 5, + } + }, trainrunCategories: [ { id: 0, diff --git a/src/integration-testing/netzgrafik.unit.testing.ts b/src/integration-testing/netzgrafik.unit.testing.ts index c1f00685..bfef3c89 100644 --- a/src/integration-testing/netzgrafik.unit.testing.ts +++ b/src/integration-testing/netzgrafik.unit.testing.ts @@ -820,6 +820,11 @@ export class NetzgrafikUnitTesting { ], resources: [], metadata: { + analyticsSettings: { + originDestinationSettings: { + connectionPenalty: 5, + } + }, trainrunCategories: [ { id: 0, From 9233845f12abbf4ddd91f0e754a34899b00087c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Henriot?= Date: Wed, 16 Oct 2024 13:41:42 +0200 Subject: [PATCH 2/2] fixup! feat: migrate originDestination connectionPenalty to netzgrafixDto --- documentation/DATA_MODEL_JSON.md | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/documentation/DATA_MODEL_JSON.md b/documentation/DATA_MODEL_JSON.md index 74464460..e85e5c5d 100644 --- a/documentation/DATA_MODEL_JSON.md +++ b/documentation/DATA_MODEL_JSON.md @@ -378,7 +378,8 @@ More details about TimeLock "netzgrafikColors": [], "trainrunCategories": [], "trainrunFrequencies": [], - "trainrunTimeCategories": [] + "trainrunTimeCategories": [], + "analyticsSettings": {} } ``` @@ -600,6 +601,26 @@ Define the dayTimeIntervalElement ``` - **from** : interval starts at time (include), in minute : numeric - **to** : interval ends at time (include), in minute : numeric + + +
+ +analyticsSettings: Contains settings for analytics features, such as originDestination matrix. + + + +```JSON +"analyticsSettings": { + "originDestinationSettings": { + "connectionPenalty": 5 + }, +} +``` + +- **connectionPenalty**: Cost to add for each connection, in minute : numeric + + +
---