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: update timestamps [DHIS2-14516] #452

Merged
merged 5 commits into from
Mar 1, 2023
Merged

Conversation

tomzemp
Copy link
Member

@tomzemp tomzemp commented Jan 24, 2023

See DHIS2-14516

before
the time was displayed as a relative time, but we assumed the timestamps from the server were in UTC. So for example, if my server timezone is in Europe/Oslo and it is currently 19:41 and my next job is scheduled at 45 minutes past the hour (19:45), this would display as in 1 hour because our code (+ moment) adjusted the timestamp for the assumed 1 hour time difference between CET+1 and UTC timezones

image

after
time stamps are displayed as absolute time (YYYY-MM-DD HH:MM:SS (server timezone)) with the relative time in a tooltip (this has been okayed by Joe and Jan B., see ticket)
image

@tomzemp tomzemp requested review from a team as code owners January 24, 2023 18:48
@dhis2-bot
Copy link
Contributor

dhis2-bot commented Jan 24, 2023

🚀 Deployed on https://pr-452--dhis2-scheduler.netlify.app

@dhis2-bot dhis2-bot temporarily deployed to netlify January 24, 2023 18:50 Inactive
Copy link

@geethaalwan geethaalwan left a comment

Choose a reason for hiding this comment

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

Tested successfully on 2.40 version

@tomzemp tomzemp requested review from a team and removed request for a team February 28, 2023 09:18
@dhis2-bot dhis2-bot temporarily deployed to netlify February 28, 2023 09:25 Inactive
package.json Outdated
Comment on lines 8 to 9
"test": "TZ=Etc/UTC d2-app-scripts test --coverage",
"test:watch": "TZ=Etc/UTC d2-app-scripts test --watch",
Copy link
Contributor

@ismay ismay Feb 28, 2023

Choose a reason for hiding this comment

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

I would just mock this in the test instead of globally. Otherwise it's not clear why this is being set. Plus it means that in the test you have to search for where this is being set.

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

The time zone is being mocked as part of the mock of the useTimeZoneConversion hook, so we don't actually need to set it generally for the test (I think this is left over from some other approach I did not use). I've just removed this.

Copy link
Contributor

@ismay ismay left a comment

Choose a reason for hiding this comment

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

Maybe I missed this discussion, but why did we change from relative to absolute time? Relative time seems simpler to parse for a user to me. We could have the actual time in a tooltip as the more detailed option.

edit: ok, I see I did miss some discussion, and that Joe and Jan B. ok'ed this. Tbh., I would find the inverse more user friendly, but if this is not up for discussion at this stage I'll defer to the existing consensus. It just doesn't seem very user friendly to me as the information that seems easier to me to understand (the relative time) is presented as the secondary option.

Comment on lines 24 to 31
/**
* The recommendation is to run dhis2 on a server set to UTC time.
* In that case this timestamp is also UTC. If those recommendations
* weren't followed the time could be off, but there's nothing
* we can do to detect that.
*/
const nextRun = moment.utc(nextExecutionTime)
const nextRunIsInPast = nextRun.isSameOrBefore(now, 'minute')
const nextRun = fromServerDate(nextExecutionTime)
const nextRunIsInPast = nextRun.getTime() <= now
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this comment still accurate now that we're converting between timezones? It should correct for a server set in a different TZ right?

Copy link
Contributor

@ismay ismay Feb 28, 2023

Choose a reason for hiding this comment

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

What I'm saying is, this could be removed, right?

If those recommendations
* weren't followed the time could be off, but there's nothing
* we can do to detect that.

Since we're now detecting TZ differences and correcting for them. Or not? (And the rest of the comment reworded)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes; going to remove 👍 (when I get around to updating the PR)

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated the comment to say Adjust for client/sever time zone difference. (rather than say we cannot detect it)

@dhis2-bot dhis2-bot temporarily deployed to netlify February 28, 2023 13:48 Inactive
@dhis2-bot dhis2-bot temporarily deployed to netlify March 1, 2023 14:47 Inactive
@tomzemp tomzemp merged commit b8564e1 into master Mar 1, 2023
@tomzemp tomzemp deleted the DHIS2-14516/fix-time-stamps branch March 1, 2023 15:25
dhis2-bot added a commit that referenced this pull request Mar 1, 2023
## [100.2.10](v100.2.9...v100.2.10) (2023-03-01)

### Bug Fixes

* adjust for server timezone [DHIS2-14516] ([8ce5e40](8ce5e40))
* clean up tests [DHIS2-14516] ([9b82265](9b82265))
* retrigger CI ([466c00e](466c00e))
* update from PR comments ([6a04f3f](6a04f3f))
* update timestamps [DHIS2-14516] ([#452](#452)) ([b8564e1](b8564e1))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 100.2.10 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants