Render analytics graph timestamps in the viewer's local timezone - #218
Merged
Conversation
Bucket timestamps were stored as naive UTC datetimes and serialized without an offset, so the browser parsed them as local time while the chart then re-formatted them with timeZone: "UTC" — showing neither true UTC nor local time. Tag the timestamp as UTC in the DTO and drop the forced UTC formatting so the chart renders in local time. Closes #215
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The analytics dashboard graph was displaying pageview timestamps that were
neither correctly UTC nor correctly local — timestamps returned by the API
were naive UTC datetimes with no offset, so the browser parsed them as
local time, and the chart then re-formatted that (already-shifted) value
with
timeZone: "UTC", compounding the error. Depending on the viewer'stimezone, the labeled times could be off by hours in either direction.
Changes:
DailyPageViewCountDTO.day(backend/app/schemas/analytics.py)to attach UTC tzinfo to the naive datetime before serialization, so the
API response carries a proper
Zoffset the client can parse unambiguouslytimeZone: "UTC"informatBucketLabel(frontend/src/components/admin/AnalyticsCharts.tsx) so the chart now
renders timestamps in the viewer's local timezone by default
UTC-tagging behavior
Closes #215