From 4fe121ef34acd58c02d505aa9120081977af310f Mon Sep 17 00:00:00 2001 From: arsforza Date: Fri, 15 Mar 2024 11:55:04 +0100 Subject: [PATCH] fix: move glofas mock to scenarios AB#26938 --- .../floods/UGA/default/glofas-stations.json | 58 +++++++++++++++++++ .../warning-to-trigger/glofas-stations.json | 58 +++++++++++++++++++ .../UGA/warnings-only/glofas-stations.json | 58 +++++++++++++++++++ .../API-service/src/scripts/mock.service.ts | 21 ++----- 4 files changed, 179 insertions(+), 16 deletions(-) create mode 100644 services/API-service/src/scripts/mock-data/floods/UGA/default/glofas-stations.json create mode 100644 services/API-service/src/scripts/mock-data/floods/UGA/warning-to-trigger/glofas-stations.json create mode 100644 services/API-service/src/scripts/mock-data/floods/UGA/warnings-only/glofas-stations.json diff --git a/services/API-service/src/scripts/mock-data/floods/UGA/default/glofas-stations.json b/services/API-service/src/scripts/mock-data/floods/UGA/default/glofas-stations.json new file mode 100644 index 000000000..1eb6e6a70 --- /dev/null +++ b/services/API-service/src/scripts/mock-data/floods/UGA/default/glofas-stations.json @@ -0,0 +1,58 @@ +[ + { + "stationCode": "G5075", + "forecastLevel": 175, + "eapAlertClass": "min", + "forecastReturnPeriod": 2, + "triggerLevel": 520 + }, + { + "stationCode": "G5160", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5189", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5196", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5220", + "forecastLevel": 600, + "eapAlertClass": "max", + "forecastReturnPeriod": 20, + "triggerLevel": 400 + }, + { + "stationCode": "G5227", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5230", + "forecastLevel": 250, + "eapAlertClass": "med", + "forecastReturnPeriod": 3, + "triggerLevel": 300 + }, + { + "stationCode": "G5317", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + } +] diff --git a/services/API-service/src/scripts/mock-data/floods/UGA/warning-to-trigger/glofas-stations.json b/services/API-service/src/scripts/mock-data/floods/UGA/warning-to-trigger/glofas-stations.json new file mode 100644 index 000000000..563213e45 --- /dev/null +++ b/services/API-service/src/scripts/mock-data/floods/UGA/warning-to-trigger/glofas-stations.json @@ -0,0 +1,58 @@ +[ + { + "stationCode": "G5075", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 520 + }, + { + "stationCode": "G5160", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5189", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5196", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5220", + "forecastLevel": 600, + "eapAlertClass": "max", + "forecastReturnPeriod": 20, + "triggerLevel": 400 + }, + { + "stationCode": "G5227", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5230", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 300 + }, + { + "stationCode": "G5317", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + } +] diff --git a/services/API-service/src/scripts/mock-data/floods/UGA/warnings-only/glofas-stations.json b/services/API-service/src/scripts/mock-data/floods/UGA/warnings-only/glofas-stations.json new file mode 100644 index 000000000..d6406ba33 --- /dev/null +++ b/services/API-service/src/scripts/mock-data/floods/UGA/warnings-only/glofas-stations.json @@ -0,0 +1,58 @@ +[ + { + "stationCode": "G5075", + "forecastLevel": 175, + "eapAlertClass": "min", + "forecastReturnPeriod": 2, + "triggerLevel": 520 + }, + { + "stationCode": "G5160", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5189", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5196", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5220", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5227", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + }, + { + "stationCode": "G5230", + "forecastLevel": 250, + "eapAlertClass": "med", + "forecastReturnPeriod": 3, + "triggerLevel": 300 + }, + { + "stationCode": "G5317", + "forecastLevel": 0, + "eapAlertClass": "no", + "forecastReturnPeriod": null, + "triggerLevel": 400 + } +] diff --git a/services/API-service/src/scripts/mock.service.ts b/services/API-service/src/scripts/mock.service.ts index 8904358a1..dc4b05c4d 100644 --- a/services/API-service/src/scripts/mock.service.ts +++ b/services/API-service/src/scripts/mock.service.ts @@ -174,7 +174,7 @@ export class MockService { selectedCountry, DisasterType.Floods, mockBody.date, - scenario.events, + mockBody.scenario, ); } } @@ -244,22 +244,11 @@ export class MockService { selectedCountry, disasterType: DisasterType, date: Date, - events: { eventName: string; leadTime: LeadTime }[], + scenarioName: string, ) { - const triggeredStations = this.getFile( - `./src/api/point-data/dto/example/glofas-stations/glofas-stations-${selectedCountry.countryCodeISO3}-triggered.json`, - ).filter((station) => - events.map((e) => e.eventName).includes(station.stationCode), - ); - console.log('triggeredStations: ', triggeredStations); - - const nonTriggeredStations = this.getFile( - `./src/api/point-data/dto/example/glofas-stations/glofas-stations-${selectedCountry.countryCodeISO3}.json`, - ).filter( - (station) => - !events.map((e) => e.eventName).includes(station.stationCode), + const stationForecasts = this.getFile( + `./src/scripts/mock-data/${disasterType}/${selectedCountry.countryCodeISO3}/${scenarioName}/glofas-stations.json`, ); - console.log('nonTriggeredStations: ', nonTriggeredStations); for (const activeLeadTime of selectedCountry.countryDisasterSettings.find( (s) => s.disasterType === disasterType, @@ -269,7 +258,7 @@ export class MockService { ); await this.glofasStationService.uploadTriggerDataPerStation({ countryCodeISO3: selectedCountry.countryCodeISO3, - stationForecasts: [...triggeredStations, ...nonTriggeredStations], + stationForecasts, leadTime: activeLeadTime as LeadTime, date, });