-
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
Daily count stats bug #2244
Comments
Weekly stats should start on Monday and end on Sunday, but front-end-monorepo/packages/app-project/stores/YourStats.spec.js Lines 90 to 102 in d172ab2
I'm not sure why the first day's classifications are being shown on Sunday and also on Monday, but I suspect that's a bug in the check for the current day here: Line 26 in fae3e5e
|
Maybe we should do all our time calculations for the graph in Zulu time (UTC) and ignore the JS locale. |
See also zooniverse/Panoptes-Front-End#3734 where this has come up before (local timezones being off with respect to the stats timestamps.) |
|
It turns out we’ve run into this problem before. #1128 (comment) |
I think replacing
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date |
It's hard to debug this in a UK time zone, but I think const monday = new Date("2021-08-16T00:00:00Z")
// this is 1 (Monday) in the UK, 0 (Sunday) in a US time zone.
console.log(monday.getDay())
// I think this will be 1 (Monday) anywhere in the world.
console.log(monday.getUTCDay()) |
The day names for the graph labels also need changes. const monday = new Date("2021-08-16T00:00:00Z")
// This prints Monday in the UK, Sunday in a US time zone.
console.log(monday.toLocaleDateString('en', { weekday: 'long' }))
// This prints Monday anywhere in the world.
console.log(console.log(monday.toLocaleDateString('en', { timeZone: 'UTC', weekday: 'long' }))) |
#2359 should fix this by explicitly using UTC for the dates sent back by the stats API. Local time is only used when figuring out the current day of the week, so that we can update your classification count for today after each new classification. |
I'm not sure what happens if you classify after midnight UTC eg. 9pm CDT (2am UTC.) I assume the stats service adds those classifications to tomorrow's count? |
@goplayoutside3 this bug has regressed. See https://www.zooniverse.org/talk/17/3466158?comment=5709216 It was fixed, with tests, in #2359, but those tests were removed in #5210. The missing tests are the tests that check the day name and classification count for each bar of the chart. I think the bug is this line here, which can return the wrong result for today when your local clock isn’t UTC. Line 18 in efe06db
Eg. during the evening in Chicago, your local clock could be Wednesday but the UTC day would be Thursday. If the code updates Wednesday, when you press Done, it will actually increment yesterday’s count. |
Should this line be Line 20 in 963abe8
|
Just noticed, looking at the mocks in the test, that the move to ERAS changed Looking at the screenshots at the top of this issue, the original code was written to use midnight UTC for each weekday, eg. EDIT: Looks like the mocks don't match real API data. Real responses do have full UTC timestamps. |
I've opened #6412 to add the missing timestamps to the mock ERAS data, and run the tests with a time in the Here's {
period: '2019-09-30',
dayNumber: 1,
weekDay: 2019-09-30T01:00:00.000Z,
count: 12
}
{
period: '2019-10-01',
dayNumber: 2,
weekDay: 2019-10-01T01:00:00.000Z,
count: 13
}
{
period: '2019-10-02',
dayNumber: 3,
weekDay: 2019-10-02T01:00:00.000Z,
count: 14
}
{
period: '2019-10-03',
dayNumber: 4,
weekDay: 2019-10-03T01:00:00.000Z,
count: 10
}
{
period: '2019-10-04',
dayNumber: 5,
weekDay: 2019-10-04T01:00:00.000Z,
count: 11
}
{
period: '2019-10-05',
dayNumber: 6,
weekDay: 2019-10-05T01:00:00.000Z,
count: 8
}
{
period: '2019-10-06',
dayNumber: 0,
weekDay: 2019-10-06T01:00:00.000Z,
count: 15
} |
Some context on stats and classifications across timezones: Stats bucketed by days always use UTC and not a user’s local timezone. ERAS classifications come from Panoptes' classification A user scenario where the user is in a different day than UTC:
The labeling on Your Stats and its design were pre-ERAS, but regardless of the stats data, the component’s goal of accurately showing a user the number of classifications they’ve submitted “today” is really difficult to keep track of and display in a bar chart of week days accurately. Rather than bug fixing the current YourStats code, some changes to the design are being discussed to bring the component in line with a user's |
I think I've fixed the bug that was returning the wrong weekday as the start of the week. Tested by running the tests in Guam, Kuala Lumpur, Chicago, and London. The tests in #6412 passed each time. I missed this line when I converted the weekly stats to use UTC. It should use front-end-monorepo/packages/app-project/stores/User/UserPersonalization/YourStats/YourStats.js Line 77 in 798a2ad
|
Since #2359, the days shown in the daily stats chart have been UTC for just this reason. That also brought them in line with the UTC days shown on the project stats page. “Today” on the daily stats chart and the project stats page is whatever the current day is in Greenwich. Every now and again there’s a Talk comment from someone working in the US in the evening, asking why the project stats graphs are showing “tomorrow” but I think the mods mostly know that all the stats are UTC now. |
Package app-project
Describe the bug
A clear and concise description of what the bug is.
Found while doing follow up testing for #2238. I was testing to make sure I didn't introduce a regression and found a bug that is pre-existing on production. I'm wondering if this is a bug having to do with the localization happening in
DailyClassificationsChartContainer
here:front-end-monorepo/packages/app-project/src/screens/ClassifyPage/components/YourStats/components/DailyClassificationsChart/DailyClassificationsChartContainer.js
Lines 23 to 31 in fae3e5e
Anyway, I made a classification on Monday and the bar chart shows I have one on Sunday and Monday even though I didn't actually on Sunday:
What it's rendering:
The original store data is correct:
And in the response from the stats service:
So the culprit is likely the above noted function.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
A clear and concise description of what you expected to happen.
Only counts render on the days a volunteer has made them. Note the data from the stats service is correct. This is just a rendering bug.
The text was updated successfully, but these errors were encountered: