From 3d1741c904b417bf7e69092b7c12d0dac137b057 Mon Sep 17 00:00:00 2001 From: Reagan Elm Date: Sat, 10 Feb 2018 20:53:38 -0500 Subject: [PATCH 1/2] Respect maxNumberOfDays regardless of endpoint --- modules/default/weatherforecast/weatherforecast.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/modules/default/weatherforecast/weatherforecast.js b/modules/default/weatherforecast/weatherforecast.js index 22322bf3..a95347d9 100644 --- a/modules/default/weatherforecast/weatherforecast.js +++ b/modules/default/weatherforecast/weatherforecast.js @@ -259,7 +259,6 @@ Module.register("weatherforecast",{ if (self.config.forecastEndpoint == "forecast/daily") { self.config.forecastEndpoint = "forecast"; - self.config.maxNumberOfDays = self.config.maxNumberOfDays * 8; Log.warn(self.name + ": Your AppID does not support long term forecasts. Switching to fallback endpoint."); } @@ -298,12 +297,6 @@ Module.register("weatherforecast",{ params += "&units=" + this.config.units; params += "&lang=" + this.config.lang; - /* - * Submit a specific number of days to forecast, between 1 to 16 days. - * The OpenWeatherMap API properly handles values outside of the 1 - 16 range and returns 7 days by default. - * This is simply being pedantic and doing it ourselves. - */ - params += "&cnt=" + (((this.config.maxNumberOfDays < 1) || (this.config.maxNumberOfDays > 16)) ? 7 * 8 : this.config.maxNumberOfDays); params += "&APPID=" + this.config.appid; return params; @@ -354,6 +347,11 @@ Module.register("weatherforecast",{ this.forecast.push(forecastData); lastDay = day; + + // Stop processing when maxNumberOfDays is reached + if (this.forecast.length === this.config.maxNumberOfDays) { + break; + } } else { //Log.log("Compare max: ", forecast.temp.max, parseFloat(forecastData.maxTemp)); forecastData.maxTemp = forecast.temp.max > parseFloat(forecastData.maxTemp) ? this.roundValue(forecast.temp.max) : forecastData.maxTemp; From 613f9fccd260e6e12691eae5f3ad4031eacb8a9f Mon Sep 17 00:00:00 2001 From: Reagan Elm Date: Sat, 10 Feb 2018 20:56:10 -0500 Subject: [PATCH 2/2] Update changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f1c3cb6d..a7625d52 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed - News article in fullscreen (iframe) is now shown in front of modules. +- Forecast respects maxNumberOfDays regardless of endpoint. *This release is scheduled to be released on 2018-04-01.*