Skip to content
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

feat(person-on-events): Person on events trends #9645

Merged
merged 70 commits into from
May 23, 2022

Conversation

EDsCODE
Copy link
Member

@EDsCODE EDsCODE commented May 4, 2022

Problem

  • scoped down the work to just account for trends
  • example test case
  • Adds a personpropertiesmode
  • Adds a setting for teams to whitelist

Changes

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

How did you test this code?

@EDsCODE EDsCODE marked this pull request as draft May 5, 2022 00:08
@EDsCODE EDsCODE changed the base branch from master to refactor-eventserializer May 10, 2022 17:29
@neilkakkar neilkakkar mentioned this pull request May 16, 2022
19 tasks
@neilkakkar neilkakkar self-assigned this May 17, 2022
FROM events e
INNER JOIN ({GET_TEAM_PERSON_DISTINCT_IDS}) as pdi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was a nasty bug. Always having these here meant we'll have two pdi joins when we also want to join persons

https://sentry.io/organizations/posthog2/issues/3154668145/?query=is%3Aunresolved

@neilkakkar neilkakkar marked this pull request as ready for review May 19, 2022 10:58
@@ -95,10 +95,11 @@ def actor_query(self, limit_actors: Optional[bool] = True) -> Tuple[str, Dict]:
filter=self._filter,
team=self._team,
entity=self.entity,
should_join_distinct_ids=not self.is_aggregating_by_groups,
should_join_persons=not self.is_aggregating_by_groups,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Person join only needs to happen if we have person properties to handle, not every time. (Notice snapshot tests being updated, where the person join was unnecessary)

@@ -59,7 +60,7 @@ def __init__(
self._should_join_distinct_ids = should_join_distinct_ids
self._should_join_persons = should_join_persons
self._extra_fields = extra_fields
self._extra_person_fields = extra_person_fields
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annoying diff: extra_person_fields are set in a line above

@@ -186,7 +186,7 @@
GROUP BY entrance_period_start) data
RIGHT OUTER JOIN
(SELECT toStartOfDay(toDateTime('2021-04-30 07:00:00') + toIntervalDay(number), 'US/Pacific') AS entrance_period_start
FROM numbers(dateDiff('day', toDateTime('2021-04-30 07:00:00'), toDateTime('2021-05-08 06:59:59')) + 1) AS period_offsets) fill USING (entrance_period_start)
FROM numbers(dateDiff('day', toDateTime('2021-04-30 07:00:00'), toDateTime('2021-05-07 07:00:00')) + 1) AS period_offsets) fill USING (entrance_period_start)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, why are these changes happening in my PR? 🤔

CH version change issue?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes: #9885

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

ee/clickhouse/queries/breakdown_props.py Show resolved Hide resolved
ee/clickhouse/models/event.py Show resolved Hide resolved
with override_instance_config("ENABLE_ACTOR_ON_EVENTS_TEAMS", f"{self.team.pk}"):
new_response = ClickhouseTrends().run(filter, self.team)

self.assertEqual(response, new_response)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still want this now that we have new testing pattern?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. Will get rid of it

@EDsCODE
Copy link
Member Author

EDsCODE commented May 23, 2022

@neilkakkar This should be good to go!

@@ -1849,6 +1814,20 @@ def test_person_property_filtering(self):
),
self.team,
)

with freeze_time("2020-01-04"), override_instance_config("ENABLE_ACTOR_ON_EVENTS_TEAMS", f"{self.team.pk}"):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will remove in a follow up 🙈

@neilkakkar neilkakkar merged commit df17af3 into master May 23, 2022
@neilkakkar neilkakkar deleted the person-on-events-trends branch May 23, 2022 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants