Skip to content

Commit

Permalink
fix(funnels): actors modal for groups (#21612)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Apr 17, 2024
1 parent 60ddec2 commit a6899dd
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions posthog/hogql_queries/insights/insight_actors_query_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
HogQLQueryResponse,
StickinessQuery,
TrendsQuery,
FunnelsQuery,
)
from posthog.types import InsightActorsQueryNode

Expand Down Expand Up @@ -84,6 +85,11 @@ def group_type_index(self) -> int | None:
assert isinstance(self.query.source, FunnelCorrelationQuery)
return self.query.source.source.source.aggregation_group_type_index

if isinstance(self.source_runner, FunnelsQueryRunner):
assert isinstance(self.query, FunnelsActorsQuery)
assert isinstance(self.query.source, FunnelsQuery)
return self.query.source.aggregation_group_type_index

if (
isinstance(self.source_runner, StickinessQueryRunner) and isinstance(self.query.source, StickinessQuery)
) or (isinstance(self.source_runner, TrendsQueryRunner) and isinstance(self.query.source, TrendsQuery)):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,32 @@ def test_insight_persons_funnels_query(self):
)

self.assertEqual([("p1",), ("p2",)], response.results)

def test_insight_groups_funnels_query(self):
self._create_test_groups()
self._create_test_events()
self.team.timezone = "US/Pacific"
self.team.save()

response = self.select(
"""
select * from (
<ActorsQuery select={['properties.name']}>
<FunnelsActorsQuery funnelStep={2}>
<FunnelsQuery
aggregation_group_type_index={0}
dateRange={<DateRange date_from='2020-01-01' date_to='2020-01-19' />}
series={[<EventsNode event='$pageview' />, <EventsNode event='$pageview' />]}
/>
</FunnelsActorsQuery>
</ActorsQuery>
)
"""
)

self.assertEqual(
[
("org1",),
],
response.results,
)

0 comments on commit a6899dd

Please sign in to comment.