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

Fix New Year Errors #8288

Merged
merged 5 commits into from
Dec 30, 2024
Merged

Fix New Year Errors #8288

merged 5 commits into from
Dec 30, 2024

Conversation

jrjohnson
Copy link
Member

@jrjohnson jrjohnson commented Dec 30, 2024

Discovered several interconnected issues around the end of 2024 and the start of 2025. The most serious of these was that opening week at a glance all weeks for 2025 blew up as we were asking for 53 weeks in a 52 week year. This fixes ilios/ilios#5908.

I also discovered that the wrong title was appearing at the top of the dashboard week view during this time period as well.

At the start and end of the year we need to pay special attention to the
week, otherwise we get bad results.
Tests every single day around the year change against the reality we
expect.
If we pass invalid data to this component such as a week that cannot
exist in a year we should die much less horribly than we do right now.

Kick out an error, and then don't display a title.
This test doesn't cover this issue.
Doing this by modifying the current year didn't work. I'm not 100% sure
why, but the right way to run a single value into a Luxon DateTime is
with fromObject so I switched to this.

This prevents us from passing a bad combination of weeks in a year and
the year and blowing up the page.
@jrjohnson jrjohnson marked this pull request as ready for review December 30, 2024 11:03
Copy link
Member

@stopfstedt stopfstedt left a comment

Choose a reason for hiding this comment

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

code reviewed and click tested. LGTM.

@stopfstedt stopfstedt self-assigned this Dec 30, 2024
@stopfstedt stopfstedt added the run ui tests Run the expensive UI tests label Dec 30, 2024
@stopfstedt stopfstedt enabled auto-merge December 30, 2024 16:11
Comment on lines +21 to +25
// In this component the week always starts on Sunday, but luxon's starts on Monday
// If today is sunday, we need to add a week to get the correct Thursday
if (DateTime.now().weekday === 7) {
return thursday.plus({ weeks: 1 });
}
Copy link
Member

@stopfstedt stopfstedt Dec 30, 2024

Choose a reason for hiding this comment

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

will need revisiting. Spanish and French locales have a start of the week on Monday, not Sunday.

Luxon provides a locale-aware function for getting the day-number of the start of the week. https://moment.github.io/luxon/api-docs/index.html#infogetstartofweek

@stopfstedt stopfstedt merged commit 966882b into ilios:master Dec 30, 2024
43 checks passed
@jrjohnson jrjohnson deleted the 5908-first-week-year branch December 30, 2024 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
run ui tests Run the expensive UI tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wrong Week Showing in New Year
2 participants