-
Notifications
You must be signed in to change notification settings - Fork 429
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: usage and analytics data duplicates the current day #4529
fix: usage and analytics data duplicates the current day #4529
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
Docker builds report
|
Uffizzi Preview |
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.
LGTM apart from a couple of noop changes (whitespace?)
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4529 +/- ##
=======================================
Coverage 96.92% 96.92%
=======================================
Files 1178 1178
Lines 39623 39623
=======================================
Hits 38405 38405
Misses 1218 1218 ☔ View full report in Codecov by Sentry. |
Changes
This code fixes an issue where the current day was duplicated in the usage / analytics graphs and all other days seemed to be off by one.
The reason for this was that the influx query was using the end of the aggregation window to use as the key for the data. This PR updates all uses of
aggregateWindow
in the code to use the start of the window as the key.Note that this will mean that we get e.g. 91 results when asking for the last 90 days because it's essentially requesting the exact last (90 x 24h), so it will include today and the same chunk of the first day in the period. Without overcomplicating the query in Influx this would be difficult to solve and I think is perfectly acceptable for now.
Reference: https://docs.influxdata.com/flux/v0/stdlib/universe/aggregatewindow/#timesrc
How did you test this code?
I have updated the (mocked) tests, but obviously this isn't very useful.
@zachaysan and I ran the code against influx directly from my laptop and verified that the data was correct.