Skip to content

Commit

Permalink
fix: move glofas mock to scenarios AB#26938
Browse files Browse the repository at this point in the history
  • Loading branch information
arsforza committed Mar 15, 2024
1 parent 7308a19 commit 4fe121e
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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
}
]
Original file line number Diff line number Diff line change
@@ -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
}
]
Original file line number Diff line number Diff line change
@@ -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
}
]
21 changes: 5 additions & 16 deletions services/API-service/src/scripts/mock.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export class MockService {
selectedCountry,
DisasterType.Floods,
mockBody.date,
scenario.events,
mockBody.scenario,
);
}
}
Expand Down Expand Up @@ -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,
Expand All @@ -269,7 +258,7 @@ export class MockService {
);
await this.glofasStationService.uploadTriggerDataPerStation({
countryCodeISO3: selectedCountry.countryCodeISO3,
stationForecasts: [...triggeredStations, ...nonTriggeredStations],
stationForecasts,
leadTime: activeLeadTime as LeadTime,
date,
});
Expand Down

0 comments on commit 4fe121e

Please sign in to comment.