Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty "Night" period for certain 7-days #1316

Closed
2 tasks
eric-gade opened this issue Jun 12, 2024 · 0 comments · Fixed by #1404
Closed
2 tasks

Empty "Night" period for certain 7-days #1316

eric-gade opened this issue Jun 12, 2024 · 0 comments · Fixed by #1404
Assignees
Labels
Bug Something isn't working

Comments

@eric-gade
Copy link
Collaborator

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 is null.

Screenshot and example

Screenshot 2024-06-12 at 12 00 18 PM

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
@eric-gade eric-gade added the Bug Something isn't working label Jun 12, 2024
@eric-gade eric-gade self-assigned this Jun 12, 2024
@colinmurphy01 colinmurphy01 moved this from Inbox to Prioritized Backlog in Roadmap & Sprint Board - Weather.gov 2.0 Jun 12, 2024
@eric-gade eric-gade moved this from Prioritized Backlog to Doing in Roadmap & Sprint Board - Weather.gov 2.0 Jun 17, 2024
@eric-gade eric-gade moved this from Doing to Prioritized Backlog in Roadmap & Sprint Board - Weather.gov 2.0 Jun 17, 2024
@greg-does-weather greg-does-weather self-assigned this Jul 2, 2024
@greg-does-weather greg-does-weather moved this from Prioritized Backlog to Doing in Roadmap & Sprint Board - Weather.gov 2.0 Jul 2, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to 🎉 Done in Sprint Board - Weather.gov 2.0 Jul 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

2 participants