-
Notifications
You must be signed in to change notification settings - Fork 1.9k
fix: query elements from start of day #9827
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
Conversation
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.
Basically looks good, though you many need to add if _ != "":
(or something nicer) to avoid triggering sentry
_, date_to, date_params = parse_timestamps(filter, team=self.team) | ||
date_from = date_from_clause("toStartOfDay", True) |
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.
There's too much magic happening behind those two lines for me to be able to confidently approve them. It's the first time I see this code, and I'm not sure of all the places it can be called. However, just following the thread, how do we know in date_from_clause
that params['date_from']
is always a thing? I fear we might get unexpected sentry errors...
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 can blame @neilkakkar if it does go wrong 🤣
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.
More seriously, I'm pretty confident that the flow through this code is safe... Plus it's easy to revert if it does cause errors :)
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'd guess the place where things can go wrong in either case (trends/stats) is if how the API being called is different? For example, we're reasonably sure the trends API wouldn't bugger out because the primary caller is our code which always puts in a date_from. Idk if we can say the same for stats ( haven't looked for call sites )
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.
Yep, it's only called from toolbar heatmap. The default case is that it isn't sent - in which case it defaults to seven days ago
* master: chore: start stack once in cloud tests (#9879) feat(apps): frontend apps (#9831) chore: Fix snapshots on master (#9885) chore(apps): rename plugins to apps (#9755) refactor: Remove constance library dependency, use json-encoded model (#9852) chore(clickhouse): avoid creating kafka_events, events_mv (#9863) fix(insights): Fix timezone date issues (#9678) refactor(plugin-server): refactor the event pipeline (#9829) feat(object storage): add unused object storage (#9846) fix: make kafka health check timeout test reliable (#9857) fix: query elements from start of day (#9827)
Problem
see #9770 - doesn't fix this issue by itself, but should help
when loading a trend view of an action (which in this case tracks clicks) we query including a
date_from
filter likewhen loading the elements for the toolbar's heat map we query including a
date_from
filter likewithout the
toStartOfDay
ClickHouse functionrunning this for a particular test action gave 72 results for the trend and 69 for the heat map
Changes
ensures the api/elements/stats endpoint queries from the start of the day
How did you test this code?
adding a unit test for the new behaviour