From 29d95d9122310f0ffbbdd4cbf082bb434d0dbbf2 Mon Sep 17 00:00:00 2001 From: Pierre-Gilles Leymarie Date: Thu, 21 Mar 2024 11:13:50 +0100 Subject: [PATCH] OpenWeather: Display next 8 slots of 3 hours instead of offsetting by 1 (#2043) --- .../services/openweather/lib/formatResults.js | 2 +- .../services/openweather/expected-result.json | 20 +++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/server/services/openweather/lib/formatResults.js b/server/services/openweather/lib/formatResults.js index 1aaff9ac0f..17a7d6d15a 100644 --- a/server/services/openweather/lib/formatResults.js +++ b/server/services/openweather/lib/formatResults.js @@ -51,7 +51,7 @@ function formatResults(options, result, forecast) { if (forecast) { dataToReturn.hours = []; - for (let i = 1; i < 9; i += 1) { + for (let i = 0; i < 8; i += 1) { dataToReturn.hours.push({ temperature: Math.round(forecast.list[i].main.temp), humidity: forecast.list[i].main.humidity, diff --git a/server/test/services/openweather/expected-result.json b/server/test/services/openweather/expected-result.json index 80ac533478..1f53cc0b81 100644 --- a/server/test/services/openweather/expected-result.json +++ b/server/test/services/openweather/expected-result.json @@ -8,6 +8,16 @@ "wind_direction": 300, "weather": "cloud", "hours": [ + { + "temperature": 15, + "humidity": 78, + "pressure": 1018, + "datetime": "2023-05-01T12:00:00.000Z", + "units": "metric", + "wind_speed": 4.01, + "wind_direction": 298, + "weather": "rain" + }, { "temperature": 15, "humidity": 77, @@ -77,16 +87,6 @@ "wind_speed": 2.01, "wind_direction": 8, "weather": "cloud" - }, - { - "temperature": 17, - "humidity": 52, - "pressure": 1022, - "datetime": "2023-05-02T12:00:00.000Z", - "units": "metric", - "wind_speed": 2.92, - "wind_direction": 20, - "weather": "cloud" } ], "days": [