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

Dealing with "overnight" periods #1017

Merged
merged 16 commits into from
Apr 10, 2024
Merged

Conversation

eric-gade
Copy link
Collaborator

What does this PR do? 🛠️

In #885 we discovered that under certain conditions (see below), a user could see three "today" periods for the daily forecast, in addition to the normally expected one or two periods (day/night).

The new period called "overnight" corresponds to the period midnight to 6am for the location. If the user is looking at the weather for a location whose current time (at the location) is between those hours, they will see this additional overnight period. We caught this by looking at Hawaii from the east coast before noon.

This PR addresses the overarching issue (display the information in a better way), while dealing with many under the hood changes / newly discovered bugfixes that make it possible.

What does the reviewer need to know? 🤔

Added Honolulu bundles for testing

We have added some slightly modified bundles from Honolulu -- where the issue was first noticed -- to the testing and e2e example sets. These will be used only in automated testing.

DailyForecastTrait future days filtering and testing $now from block build

We have slightly altered how we filter out future daily periods. Previously, the $now time was computed after these filtration, meaning that the current user's time in their own timezone was always being used as the cutoff. This prevented accurate testing of the overnight period issue.

Additionally, the DailyForecastBlock's build() method now takes a $now DateTime as an optional parameter, and passes it down to the helper methods. The e2e test added in this PR makes use of that.

Can't see live in the browser with the bundle alone

Unlike all our other cases of testing with bundles, you will not be able to "see" the overnight period even when looking at the example bundle unless you look between midnight and 6am of the current day. This is because the bundler dates are all relative to the current time, and there is no way from the outside to force the Drupal application to pretend the current time is anything other than what it really is.

Updates to computing high/low

Because the "today" period can have three periods, determining the high/low by day/night is now more ambiguous. Instead, we have adjusted all calculation of high/low to simply take the highest and lowest temperatures returned for each daily period. In most cases the day will still be the high and the night will still be the low. This does not make use of the corresponding hourly data.

Extended periods might only have a "high" value

When there is an "overnight" period, it is not added as an extra period to the number that the API usually provides. This means that the last daily period returned by the API only has a daytime component, the result being we can only display a "high" for that extended day (see third screenshot below).

Closes

#885

Screenshots (if appropriate): 📸

Before: Screen Shot 2024-04-05 at 9 25 48 AM
After: Screen Shot 2024-04-05 at 9 25 32 AM
Extended high-only example: Screen Shot 2024-04-05 at 2 02 20 PM

Copy link
Collaborator

@greg-does-weather greg-does-weather left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eng approved

@eric-gade
Copy link
Collaborator Author

@partly-igor double check the most recent push, I think I addressed the styling issues properly?

@eric-gade eric-gade force-pushed the eg-885-overnight-today-period branch from 0d9da6a to ba6186d Compare April 9, 2024 20:08
Copy link
Contributor

github-actions bot commented Apr 9, 2024

This PR modifies theme Javascript or CSS assets but does not update the theme libraries file. Did you mean to update the appropriate version information in the libraries file?

Copy link
Contributor

github-actions bot commented Apr 9, 2024

This PR modifies theme Javascript or CSS assets but does not update the theme libraries file. Did you mean to update the appropriate version information in the libraries file?

@eric-gade eric-gade added this pull request to the merge queue Apr 10, 2024
Merged via the queue into main with commit fbb16da Apr 10, 2024
12 checks passed
@eric-gade eric-gade deleted the eg-885-overnight-today-period branch April 10, 2024 14:29
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants