mirror of
https://github.com/PostHog/posthog.git
synced 2024-12-01 12:21:02 +01:00
4e0e69ac91
* separate class * filter typing * remove repeat * refactor test * add limits * remove ee * working tests * working group tests for stickiness * remove inits * suggested changes * typing * adjust typing * add correct params * remove repeat
30 lines
1.2 KiB
Python
30 lines
1.2 KiB
Python
from typing import List, Optional, cast
|
|
|
|
from ee.clickhouse.queries.actor_base_query import ActorBaseQuery
|
|
from ee.clickhouse.queries.funnels.funnel import ClickhouseFunnel
|
|
from ee.clickhouse.sql.funnels.funnel import FUNNEL_PERSONS_BY_STEP_SQL
|
|
from posthog.models import Person
|
|
from posthog.models.filters.filter import Filter
|
|
from posthog.models.filters.mixins.utils import cached_property
|
|
|
|
|
|
class ClickhouseFunnelActors(ClickhouseFunnel, ActorBaseQuery):
|
|
_filter: Filter
|
|
|
|
@cached_property
|
|
def is_aggregating_by_groups(self) -> bool:
|
|
return self._filter.aggregation_group_type_index is not None
|
|
|
|
def actor_query(self, extra_fields: Optional[List[str]] = None):
|
|
extra_fields_string = ", ".join([self._get_timestamp_outer_select()] + (extra_fields or []))
|
|
return (
|
|
FUNNEL_PERSONS_BY_STEP_SQL.format(
|
|
offset=self._filter.offset,
|
|
steps_per_person_query=self.get_step_counts_query(),
|
|
persons_steps=self._get_funnel_person_step_condition(),
|
|
extra_fields=extra_fields_string,
|
|
limit="" if self._no_person_limit else "LIMIT %(limit)s",
|
|
),
|
|
self.params,
|
|
)
|