-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Group reamining breakdown values into "Other" for funnels #5538
Changes from 1 commit
d6dc76a
b8baecb
903f3d2
4c4b5c2
393a7ad
7a55959
18a2511
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -397,30 +397,24 @@ def _get_cohort_breakdown_join(self) -> str: | |
|
||
def _get_breakdown_conditions(self) -> str: | ||
if self._filter.breakdown: | ||
if self._filter.funnel_step_breakdown: | ||
values = self._parse_breakdown_prop_value() | ||
else: | ||
limit = self._filter.breakdown_limit_or_default | ||
first_entity = next(x for x in self._filter.entities if x.order == 0) | ||
if not first_entity: | ||
ValidationError("An entity with order 0 was not provided") | ||
values = [] | ||
if self._filter.breakdown_type == "person": | ||
values = get_breakdown_person_prop_values( | ||
self._filter, first_entity, "count(*)", self._team.pk, limit | ||
) | ||
elif self._filter.breakdown_type == "event": | ||
values = get_breakdown_event_prop_values( | ||
self._filter, first_entity, "count(*)", self._team.pk, limit | ||
) | ||
limit = self._filter.breakdown_limit_or_default | ||
first_entity = next(x for x in self._filter.entities if x.order == 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code issue: This doesn't work as you'd like:
Given that entities are sorted already entities[0] does the trick There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense! I guess we never hit this earlier because we have a check that entities exist. I'm just going to get rid of the validation error completely! |
||
if not first_entity: | ||
ValidationError("An entity with order 0 was not provided") | ||
values = [] | ||
if self._filter.breakdown_type == "person": | ||
values = get_breakdown_person_prop_values(self._filter, first_entity, "count(*)", self._team.pk, limit) | ||
elif self._filter.breakdown_type == "event": | ||
values = get_breakdown_event_prop_values(self._filter, first_entity, "count(*)", self._team.pk, limit) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So what happens if the second entity has a different set of person property values? Is it impossible due to how funnels work? If so, worth adding a comment. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you mean by different set of person property values for second entity? Maybe an example? If you mean something like: breakdown by X, and second entity has a filter like: X=a, where a is very rare, then earlier, yes, this would mean that drop off is 100%. After this PR, they'd all get grouped into "Other". There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So entities in this case are things like:
Let's walk through a scenario Would the table contain A and B only or would C get included as well or is this scenario impossible? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Earlier: Now: Judging possibility: The idea with choosing the first event: anything that occurs for the Nth event but not the first event wouldn't make it inside the funnel, since the first event needs to happen ... first. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope you see now why this needs at minimum a clarifying comment - there's a ton to unpack here. Why Given you can break down by event properties, it's more than possible that the second step in the funnel has a different set of properties than the first. It's kind of how event properties work - they don't stick around for all events for a session. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I see what you mean now, "Why other not C" is a very valid question! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh wait, actually, in the funnel, all event properties are constrained to the first in line, so even with other grouping, the breakdown values would only be I'll chalk this one up to a funnel limitation. With event props, makes sense to extend this like you say. @EDsCODE can confirm? |
||
|
||
self.params.update({"breakdown_values": values}) | ||
return "prop IN %(breakdown_values)s" | ||
else: | ||
return "" | ||
|
||
def _get_breakdown_prop(self) -> str: | ||
def _get_breakdown_prop(self, group_remaining=False) -> str: | ||
if self._filter.breakdown: | ||
return ", prop" | ||
if group_remaining and self._filter.breakdown_type != "cohort": | ||
return ", if(has(%(breakdown_values)s, prop), prop, 'Other') as prop" | ||
else: | ||
return ", prop" | ||
else: | ||
return "" |
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.
this pattern is turning out to be a bit icky, where this function modifies state (
self.params
) and returns empty string.Will leave refactoring to a follow up PR - it might make sense to do it for the rest of the functions like this one.