You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In cases where the final day of the 7-day forecast only has one period (just the day), the template still tries to render a night period but it is empty. We probably want to just render the day period.
I believe this is due to how array_chunk works in PHP, in that if you chunk by 2 (as we do) but there is only one item left, it will make a second item whose value is null.
Screenshot and example
API Response for Daily
{
"@context": [
"https://geojson.org/geojson-ld/geojson-context.jsonld",
{
"@version": "1.1",
"wx": "https://api.weather.gov/ontology#",
"geo": "http://www.opengis.net/ont/geosparql#",
"unit": "http://codes.wmo.int/common/unit/",
"@vocab": "https://api.weather.gov/ontology#"
}
],
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
145.7560501,
15.21917
],
[
145.7560501,
15.1960902
],
[
145.7799606,
15.1960902
],
[
145.7799606,
15.21917
],
[
145.7560501,
15.21917
]
]
]
},
"properties": {
"updated": "2024-06-12T08:03:53+00:00",
"units": "us",
"forecastGenerator": "BaselineForecastGenerator",
"generatedAt": "2024-06-12T16:07:56+00:00",
"updateTime": "2024-06-12T08:03:53+00:00",
"validTimes": "2024-06-12T02:00:00+00:00/P8DT6H",
"elevation": {
"unitCode": "wmoUnit:m",
"value": 43.8912
},
"periods": [
{
"number": 1,
"name": "Overnight",
"startTime": "2024-06-13T02:00:00+10:00",
"endTime": "2024-06-13T06:00:00+10:00",
"isDaytime": false,
"temperature": 78,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 99
},
"windSpeed": "9 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/night/tsra_hi?size=medium",
"shortForecast": "Isolated Showers And Thunderstorms",
"detailedForecast": "Isolated showers and thunderstorms. Partly cloudy, with a low around 78. East wind around 9 mph. New rainfall amounts less than a tenth of an inch possible."
},
{
"number": 2,
"name": "Thursday",
"startTime": "2024-06-13T06:00:00+10:00",
"endTime": "2024-06-13T18:00:00+10:00",
"isDaytime": true,
"temperature": 88,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": 30
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 99
},
"windSpeed": "9 to 13 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/day/tsra_hi,30?size=medium",
"shortForecast": "Scattered Showers And Thunderstorms",
"detailedForecast": "Scattered showers and thunderstorms. Partly sunny, with a high near 88. Heat index values as high as 100. East wind 9 to 13 mph, with gusts as high as 21 mph. Chance of precipitation is 30%. New rainfall amounts between a tenth and quarter of an inch possible."
},
{
"number": 3,
"name": "Thursday Night",
"startTime": "2024-06-13T18:00:00+10:00",
"endTime": "2024-06-14T06:00:00+10:00",
"isDaytime": false,
"temperature": 78,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 99
},
"windSpeed": "9 to 13 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/night/tsra_hi?size=medium",
"shortForecast": "Slight Chance Showers And Thunderstorms",
"detailedForecast": "A slight chance of showers and thunderstorms. Partly cloudy, with a low around 78. Heat index values as high as 98. East wind 9 to 13 mph. New rainfall amounts less than a tenth of an inch possible."
},
{
"number": 4,
"name": "Friday",
"startTime": "2024-06-14T06:00:00+10:00",
"endTime": "2024-06-14T18:00:00+10:00",
"isDaytime": true,
"temperature": 88,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 99
},
"windSpeed": "10 to 15 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/day/rain_showers?size=medium",
"shortForecast": "Isolated Rain Showers",
"detailedForecast": "Isolated rain showers. Mostly sunny, with a high near 88. Heat index values as high as 100. East wind 10 to 15 mph, with gusts as high as 18 mph. New rainfall amounts less than a tenth of an inch possible."
},
{
"number": 5,
"name": "Friday Night",
"startTime": "2024-06-14T18:00:00+10:00",
"endTime": "2024-06-15T06:00:00+10:00",
"isDaytime": false,
"temperature": 78,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 99
},
"windSpeed": "7 to 13 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/night/tsra_hi?size=medium",
"shortForecast": "Isolated Showers And Thunderstorms",
"detailedForecast": "Isolated showers and thunderstorms. Mostly cloudy, with a low around 78. East wind 7 to 13 mph. New rainfall amounts less than a tenth of an inch possible."
},
{
"number": 6,
"name": "Saturday",
"startTime": "2024-06-15T06:00:00+10:00",
"endTime": "2024-06-15T18:00:00+10:00",
"isDaytime": true,
"temperature": 88,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": 30
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 99
},
"windSpeed": "9 to 13 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/day/tsra_hi,30?size=medium",
"shortForecast": "Chance Showers And Thunderstorms",
"detailedForecast": "A chance of showers and thunderstorms. Partly sunny, with a high near 88. Chance of precipitation is 30%. New rainfall amounts less than a tenth of an inch possible."
},
{
"number": 7,
"name": "Saturday Night",
"startTime": "2024-06-15T18:00:00+10:00",
"endTime": "2024-06-16T06:00:00+10:00",
"isDaytime": false,
"temperature": 78,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 97
},
"windSpeed": "9 to 14 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/night/tsra_hi?size=medium",
"shortForecast": "Slight Chance Showers And Thunderstorms",
"detailedForecast": "A slight chance of showers and thunderstorms. Mostly cloudy, with a low around 78."
},
{
"number": 8,
"name": "Sunday",
"startTime": "2024-06-16T06:00:00+10:00",
"endTime": "2024-06-16T18:00:00+10:00",
"isDaytime": true,
"temperature": 88,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 97
},
"windSpeed": "10 to 14 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/day/rain_showers?size=medium",
"shortForecast": "Slight Chance Rain Showers",
"detailedForecast": "A slight chance of rain showers. Mostly sunny, with a high near 88."
},
{
"number": 9,
"name": "Sunday Night",
"startTime": "2024-06-16T18:00:00+10:00",
"endTime": "2024-06-17T06:00:00+10:00",
"isDaytime": false,
"temperature": 78,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 26.11111111111111
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 100
},
"windSpeed": "9 to 14 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/night/rain_showers?size=medium",
"shortForecast": "Slight Chance Rain Showers",
"detailedForecast": "A slight chance of rain showers. Partly cloudy, with a low around 78."
},
{
"number": 10,
"name": "Monday",
"startTime": "2024-06-17T06:00:00+10:00",
"endTime": "2024-06-17T18:00:00+10:00",
"isDaytime": true,
"temperature": 88,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 100
},
"windSpeed": "10 to 14 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/day/rain_showers?size=medium",
"shortForecast": "Slight Chance Rain Showers",
"detailedForecast": "A slight chance of rain showers. Mostly sunny, with a high near 88."
},
{
"number": 11,
"name": "Monday Night",
"startTime": "2024-06-17T18:00:00+10:00",
"endTime": "2024-06-18T06:00:00+10:00",
"isDaytime": false,
"temperature": 78,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 26.11111111111111
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 98
},
"windSpeed": "9 to 14 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/night/rain_showers?size=medium",
"shortForecast": "Slight Chance Rain Showers",
"detailedForecast": "A slight chance of rain showers. Partly cloudy, with a low around 78."
},
{
"number": 12,
"name": "Tuesday",
"startTime": "2024-06-18T06:00:00+10:00",
"endTime": "2024-06-18T18:00:00+10:00",
"isDaytime": true,
"temperature": 88,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 98
},
"windSpeed": "12 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/day/rain_showers?size=medium",
"shortForecast": "Slight Chance Rain Showers",
"detailedForecast": "A slight chance of rain showers. Mostly sunny, with a high near 88."
},
{
"number": 13,
"name": "Tuesday Night",
"startTime": "2024-06-18T18:00:00+10:00",
"endTime": "2024-06-19T06:00:00+10:00",
"isDaytime": false,
"temperature": 78,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25.555555555555557
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 96
},
"windSpeed": "8 to 12 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/night/rain_showers?size=medium",
"shortForecast": "Slight Chance Rain Showers",
"detailedForecast": "A slight chance of rain showers. Partly cloudy, with a low around 78."
},
{
"number": 14,
"name": "Juneteenth",
"startTime": "2024-06-19T06:00:00+10:00",
"endTime": "2024-06-19T18:00:00+10:00",
"isDaytime": true,
"temperature": 89,
"temperatureUnit": "F",
"temperatureTrend": null,
"probabilityOfPrecipitation": {
"unitCode": "wmoUnit:percent",
"value": null
},
"dewpoint": {
"unitCode": "wmoUnit:degC",
"value": 25
},
"relativeHumidity": {
"unitCode": "wmoUnit:percent",
"value": 96
},
"windSpeed": "12 mph",
"windDirection": "E",
"icon": "https://api.weather.gov/icons/land/day/rain_showers?size=medium",
"shortForecast": "Slight Chance Rain Showers",
"detailedForecast": "A slight chance of rain showers. Mostly sunny, with a high near 89."
}
]
}
}
Acceptance criteria
Tests have been implemented or modified to capture the bug
Changes have been tested for accessibility
The text was updated successfully, but these errors were encountered:
Description
In cases where the final day of the 7-day forecast only has one period (just the day), the template still tries to render a night period but it is empty. We probably want to just render the day period.
I believe this is due to how
array_chunk
works in PHP, in that if you chunk by 2 (as we do) but there is only one item left, it will make a second item whose value isnull
.Screenshot and example
API Response for Daily
Acceptance criteria
The text was updated successfully, but these errors were encountered: