0
0
mirror of https://github.com/PostHog/posthog.git synced 2024-12-01 12:21:02 +01:00
posthog/ee/clickhouse/queries/funnels/funnel_strict_persons.py
Karl-Aksel Puulmann a1dd96e47d
Improve cached_property typing (#5465)
* Improve cached_property typing

Noticed that e.g. `filter.breakdown` was getting inferred to be `Any`
which is not correct. Added generics to fix it :)

* Proposed fix: make filter_test_accounts return a bool always

* Fix warning in clickhouse_sessions.py

* Cast in session.events

* Cast 2x in funnel queries

* Ignore error in session recording

We know the valid values here

* Add assertions in stickiness filters

* Cast in more funnel queries

* Untyped dict where inferred type is wrong

* Add types to abstract methods

* Type prop_vals

* Add a lot of casts

These are correct. We should really validate while parsing instead

* Add more casts to funnel trends

* Last fixes
2021-08-05 22:31:31 +03:00

22 lines
836 B
Python

from typing import cast
from ee.clickhouse.queries.funnels.funnel_strict import ClickhouseFunnelStrict
from ee.clickhouse.sql.funnels.funnel import FUNNEL_PERSONS_BY_STEP_SQL
from posthog.models import Person
class ClickhouseFunnelStrictPersons(ClickhouseFunnelStrict):
def get_query(self):
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(),
)
def _format_results(self, results):
people = Person.objects.filter(team_id=self._team.pk, uuid__in=[val[0] for val in results])
from posthog.api.person import PersonSerializer
return PersonSerializer(people, many=True).data, len(results) > cast(int, self._filter.limit) - 1