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

Stats: Last 12 Months showed two years during December #6596

Open
eatyourgreens opened this issue Jan 1, 2025 · 0 comments
Open

Stats: Last 12 Months showed two years during December #6596

eatyourgreens opened this issue Jan 1, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@eatyourgreens
Copy link
Contributor

eatyourgreens commented Jan 1, 2025

Package

  • lib-user

Describe the bug

Yesterday, 31st December 2024, the Last 12 Months option was consistently showing 24 months, starting Jan 2023.

To Reproduce

I think you have to select Last 12 Months during December to reproduce this. Maybe set up a test case with a mock clock?

Expected behavior

Last 12 Months should only show 12 months.

Additional context

https://www.zooniverse.org/talk/17/3531984?comment=5824612

The bug is in value here, which subtracts 24 months from the current date when the month is December.

{
label: 'LAST 12 MONTHS',
value: getStatsDateString(new Date(Date.UTC((today.getUTCFullYear() - 1), getNextMonth(today.getUTCMonth()), 1)))
},

In December 2024, that line evaluates to:

{
      label: 'LAST 12 MONTHS',
      value: getStatsDateString(new Date(Date.UTC(2023, 0, 1)))
 },

which sets the start date to 1 Jan 2023. What the code should do here is subtract 12 months from the current date, then use that as the start date (or the first day of the next month after that date.) Alternatively, you could advance the date to the first day of the next month from the current date, then set the year number back by one. That would correct for the change in year from December to January.

# current date
2024-12-25
# advance to first of next month
2025-01-01
# back one year
2024-01-01
@eatyourgreens eatyourgreens added the bug Something isn't working label Jan 1, 2025
@eatyourgreens eatyourgreens changed the title Stats: Last 12 Months showed two years on New Years Eve Stats: Last 12 Months showed two years during December Jan 4, 2025
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
None yet
Development

No branches or pull requests

1 participant