From 1404b474528ce42714ceb5991acc5a4c4bcf10e5 Mon Sep 17 00:00:00 2001 From: dgoth <132394363+dgoth@users.noreply.github.com> Date: Wed, 6 Sep 2023 20:09:25 -0500 Subject: [PATCH 1/2] Update weathergov.js Fixed issue with probability of precipitation not showing up on hourly or daily forecast --- modules/default/weather/providers/weathergov.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/default/weather/providers/weathergov.js b/modules/default/weather/providers/weathergov.js index b1c69ee753..5e39ea9674 100644 --- a/modules/default/weather/providers/weathergov.js +++ b/modules/default/weather/providers/weathergov.js @@ -182,6 +182,12 @@ WeatherProvider.register("weathergov", { weather.windSpeed = WeatherUtils.convertWindToMs(weather.windSpeed); weather.windFromDirection = forecast.windDirection; weather.temperature = forecast.temperature; + //assign probability of precipitation + if (forecast.probabilityOfPrecipitation.value == null) { + weather.precipitationProbability = 0; + } else { + weather.precipitationProbability = forecast.probabilityOfPrecipitation.value; + } // use the forecast isDayTime attribute to help build the weatherType label weather.weatherType = this.convertWeatherType(forecast.shortForecast, forecast.isDaytime); @@ -238,8 +244,7 @@ WeatherProvider.register("weathergov", { * fetch forecast information for daily forecast. */ fetchForecastDaily(forecasts) { - const precipitationProbabilityRegEx = "Chance of precipitation is ([0-9]+?)%"; - + // initial variable declaration const days = []; // variables for temperature range and rain @@ -262,8 +267,12 @@ WeatherProvider.register("weathergov", { minTemp = []; maxTemp = []; - const precipitation = new RegExp(precipitationProbabilityRegEx, "g").exec(forecast.detailedForecast); - if (precipitation) weather.precipitationProbability = precipitation[1]; + //assign probability of precipitation + if (forecast.probabilityOfPrecipitation.value == null) { + weather.precipitationProbability = 0; + } else { + weather.precipitationProbability = forecast.probabilityOfPrecipitation.value; + } // set new date date = moment(forecast.startTime).format("YYYY-MM-DD"); From c3893cf47fd579b286dd17d8cae7717b5fff194c Mon Sep 17 00:00:00 2001 From: veeck Date: Mon, 25 Sep 2023 22:36:01 +0200 Subject: [PATCH 2/2] Add CHANGELOG, fix linting --- CHANGELOG.md | 1 + modules/default/weather/providers/weathergov.js | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bfbce86b24..bea8baeb97 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ _This release is scheduled to be released on 2023-10-01._ - Fix: AnimateCSS merge hide() and show() animated css class when we do multiple call - Fix `Uncaught SyntaxError: Identifier 'getCorsUrl' has already been declared (at utils.js:1:1)` when using `clock` and `weather` module (#3204) - Fix overriding `config.js` when running tests (#3201) +- Fix issue in weathergov provider with probability of precipitation not showing up on hourly or daily forecast ## [2.24.0] - 2023-07-01 diff --git a/modules/default/weather/providers/weathergov.js b/modules/default/weather/providers/weathergov.js index 5e39ea9674..8111044be4 100644 --- a/modules/default/weather/providers/weathergov.js +++ b/modules/default/weather/providers/weathergov.js @@ -183,7 +183,7 @@ WeatherProvider.register("weathergov", { weather.windFromDirection = forecast.windDirection; weather.temperature = forecast.temperature; //assign probability of precipitation - if (forecast.probabilityOfPrecipitation.value == null) { + if (forecast.probabilityOfPrecipitation.value === null) { weather.precipitationProbability = 0; } else { weather.precipitationProbability = forecast.probabilityOfPrecipitation.value; @@ -244,7 +244,6 @@ WeatherProvider.register("weathergov", { * fetch forecast information for daily forecast. */ fetchForecastDaily(forecasts) { - // initial variable declaration const days = []; // variables for temperature range and rain @@ -268,11 +267,11 @@ WeatherProvider.register("weathergov", { minTemp = []; maxTemp = []; //assign probability of precipitation - if (forecast.probabilityOfPrecipitation.value == null) { - weather.precipitationProbability = 0; - } else { - weather.precipitationProbability = forecast.probabilityOfPrecipitation.value; - } + if (forecast.probabilityOfPrecipitation.value === null) { + weather.precipitationProbability = 0; + } else { + weather.precipitationProbability = forecast.probabilityOfPrecipitation.value; + } // set new date date = moment(forecast.startTime).format("YYYY-MM-DD");