-
Notifications
You must be signed in to change notification settings - Fork 30
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
Use UTC for daily stats calculations #2359
Conversation
2a51a1e
to
ac41fc6
Compare
https://local.zooniverse.org:3000/projects/eatyourgreens/-project-testing-ground/classify/workflow/3223?env=staging is a Yes/No workflow on staging, which can be used to check today's classification count. I don't think daily stats are stored for staging projects. |
ac41fc6
to
6c4a2b7
Compare
...ponents/YourStats/components/DailyClassificationsChart/DailyClassificationsChartContainer.js
Outdated
Show resolved
Hide resolved
...ponents/YourStats/components/DailyClassificationsChart/DailyClassificationsChartContainer.js
Outdated
Show resolved
Hide resolved
...ponents/YourStats/components/DailyClassificationsChart/DailyClassificationsChartContainer.js
Outdated
Show resolved
Hide resolved
const locale = counterpart.getLocale() | ||
const stats = thisWeek.map(({ count: statsCount, period }) => { | ||
const day = new Date(period) | ||
const isToday = day.getUTCDay() === TODAY.getDay() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could put the day numbers and local names for each day in the store, so that each daily count is { count, dayNumber, label, longLabel, period }
. They never change, so only need to be generated once. Maybe something for a future rewrite of this component?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately none of the tests for the DailyClassificationChartContainer
pass running in Chicago CDT time. Everything is a day later compared to the expectation it looks like. Do you want a copy of the test failure outputs?
It's 11:22 AM if that helps. |
I think these lines in the tests are generating the local day name in Chicago, at midnight UTC. Lines 52 to 53 in 329acb5
|
329acb5
to
33584d5
Compare
@srallen I've fixed the expected day names, so the tests should pass now. I've changed the wording to make it explicit, which day is being tested for each date. This is what you should see:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still seeing failures, having to do with mismatches between Saturday and Sunday:
1) Component > DailyClassificationsChartContainer
daily stats counts
2019-10-05
should have a count:
AssertionError: expected 25 to equal 8
+ expected - actual
-25
+8
at Context.<anonymous> (src/screens/ClassifyPage/components/YourStats/components/DailyClassificationsChart/DailyClassificationsChartContainer.spec.js:121:33)
at processImmediate (internal/timers.js:464:21)
2) Component > DailyClassificationsChartContainer
daily stats counts
2019-10-05
should have an accessible description:
AssertionError: expected 'Saturday: 25' to equal 'Saturday: 8'
+ expected - actual
-Saturday: 25
+Saturday: 8
at Context.<anonymous> (src/screens/ClassifyPage/components/YourStats/components/DailyClassificationsChart/DailyClassificationsChartContainer.spec.js:137:31)
at processImmediate (internal/timers.js:464:21)
3) Component > DailyClassificationsChartContainer
daily stats counts
2019-10-06
should have a count:
AssertionError: expected 15 to equal 25
+ expected - actual
-15
+25
at Context.<anonymous> (src/screens/ClassifyPage/components/YourStats/components/DailyClassificationsChart/DailyClassificationsChartContainer.spec.js:121:33)
at processImmediate (internal/timers.js:464:21)
4) Component > DailyClassificationsChartContainer
daily stats counts
2019-10-06
should have an accessible description:
AssertionError: expected 'Sunday: 15' to equal 'Sunday: 25'
+ expected - actual
-Sunday: 15
+Sunday: 25
at Context.<anonymous> (src/screens/ClassifyPage/components/YourStats/components/DailyClassificationsChart/DailyClassificationsChartContainer.spec.js:137:31)
at processImmediate (internal/timers.js:464:21)
Ignore the local time zone and use UTC when calculating your daily classification counts. With this change, the daily stats chart should always begin on a Monday, regardless of which time zone you're in. Classifications should be shown on the day that you made them, not the day before.
Use UTC when getting day names for dates from the stats server.
Today's day number should be calculated from the local clock. Day numbers for stats data should use UTC.
Calculation of the daily counts is a bit hard to follow. This might help clarify it.
ee297d3
to
ba5e2ea
Compare
That's weird. EDIT: So the fix seems to be to run the mock clock from noon on 6th Oct 2019, which should be 7am Sunday in CST? |
ba5e2ea
to
28e4529
Compare
Don't localise the expected day names. They should be the same, regardless of which time zone and language the tests are running in. Run the mock clock at noon.
28e4529
to
9421d3d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The latest updates resolved it. Thanks!
Cool! Let's see if this resolves any issues for people who are seeing their classifications plotted on the wrong day. |
Ignore the local time zone and use UTC when calculating your daily classification counts. With this change, the daily stats chart should always begin on a Monday, regardless of which time zone you're in. Classifications should be shown on the day that you made them, not the day before.
http://localhost:9001/?path=/story/project-app-screens-classify-daily-classifications-chart--plain
I've also upgraded the chart component to remove
inject
, and upgraded the stories to removestoriesOf
.Package:
app-project
Closes #2244.
Review Checklist
General
Components
Apps
yarn panic && yarn bootstrap
ordocker-compose up --build
and app works as expected?Publishing
Post-merging