Skip to content

Commit

Permalink
hotfix: fix river-and-sea-levels looking up rainfall station
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Bladen-Clark committed Sep 29, 2023
1 parent e69cdb5 commit ee4d127
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 28 deletions.
5 changes: 2 additions & 3 deletions server/routes/river-and-sea-levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@ module.exports = [{
path: `/${route}/rainfall/{rainfallid}`,
handler: async (request, h) => {
const { rainfallid } = request.params
const rainfallStations = await request.server.methods.flood.getRainfallStation(rainfallid)
const rainfallStation = await request.server.methods.flood.getRainfallStation(rainfallid)

if (rainfallStations.length > 0) {
const rainfallStation = rainfallStations[0]
if (rainfallStation) {
const radius = 8000 // metres
const distanceInMiles = Math.round(radius / 1609.344)
const referencePoint = {
Expand Down
46 changes: 22 additions & 24 deletions test/data/cachedRainfallStation.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
[
{
"telemetry_station_id":"912",
"station_reference":"E27601",
"region":"Anglian",
"station_name":"EASTHAVEN BARRIER",
"ngr":"TQ7480084300",
"easting":574800,
"northing":184300,
"centroid":"0101000020E6100000A9324274F298E03FCC026A09E9C34940",
"data_type":"Total",
"period":"15 min",
"units":"mm",
"telemetry_value_parent_id":"105675541",
"value":"0",
"value_timestamp":"2022-03-25T04:30:00.000Z",
"day_total":"0",
"six_hr_total":"0",
"one_hr_total":"0",
"type":"R",
"lat":51.34453211,
"lon": -0.60409807
}
]
{
"telemetry_station_id": "912",
"station_reference": "E27601",
"region": "Anglian",
"station_name": "EASTHAVEN BARRIER",
"ngr": "TQ7480084300",
"easting": 574800,
"northing": 184300,
"centroid": "0101000020E6100000A9324274F298E03FCC026A09E9C34940",
"data_type": "Total",
"period": "15 min",
"units": "mm",
"telemetry_value_parent_id": "105675541",
"value": "0",
"value_timestamp": "2022-03-25T04:30:00.000Z",
"day_total": "0",
"six_hr_total": "0",
"one_hr_total": "0",
"type": "R",
"lat": 51.34453211,
"lon": -0.60409807
}
2 changes: 1 addition & 1 deletion test/routes/river-and-sea-levels.js
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ lab.experiment('Test - /river-and-sea-levels', () => {

const fakeStationsData = () => data.stationsWithinRadius

const originalStation = () => data.rainfallStation.filter(function (rainfallStation) {
const originalStation = () => data.rainfallStation.find(function (rainfallStation) {
return rainfallStation.station_reference === 'GKHLETOY'
})

Expand Down

0 comments on commit ee4d127

Please sign in to comment.