-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
fix: allow creating lifecycle static cohorts #15729
Conversation
93276cd
to
a798902
Compare
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the |
This PR was closed due to lack of activity. Feel free to reopen if it's still relevant. |
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.
Hey @psykomal - sorry it took a while for me to get to this!
This is mostly great! - Although there seems to be some duplication going on here. Have a look at PathActors
and compare it to LifecycleActors
. This place: https://github.com/PostHog/posthog/blob/master/posthog/api/person.py#L665 - shouldn't be separate from the new LifecycleActor
class you're generating.
I'd recommend combining these into one, so there's only one code path to get persons for lifecycle, which is used by both cohorts & person querying.
if target_date is None: | ||
raise ValidationError("Must include specified target date") | ||
|
||
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.
when you reconcile the two, you'll find that you can use LIFECYCLE_PEOPLE_SQL
sql from https://github.com/PostHog/posthog/blob/master/posthog/queries/trends/lifecycle.py#L61 here
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.
instead of re-writing the SQL here
a798902
to
9cf2a52
Compare
3491014
to
07c1cc9
Compare
@neilkakkar Have made the changes. Do have a look and let me know. |
posthog/queries/trends/lifecycle.py
Outdated
@@ -31,6 +27,8 @@ | |||
|
|||
|
|||
class Lifecycle: | |||
# actor_query_class = LifecycleActors |
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.
debug?
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.
my bad, removed.
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.
one comment, looks good otherwise!
07c1cc9
to
f005773
Compare
@neilkakkar also should I run ./bin/tests to update snapshots for the failing tests or is there another way? |
That's the correct way. ( |
f005773
to
3b56506
Compare
3b56506
to
34f8226
Compare
@neilkakkar updated snapshots. Please have a look. Not sure if I'm missing something but just merging didn't change anything. |
@@ -2575,6 +2615,7 @@ | |||
"posthog_team"."ingested_event", | |||
"posthog_team"."autocapture_opt_out", | |||
"posthog_team"."autocapture_exceptions_opt_in", | |||
"posthog_team"."autocapture_exceptions_errors_to_ignore", |
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.
cc: @pauldambra was this left out somehow by the job in the last PR?
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.
Oh, I've seen this recently with some dashboard changes where snapshots in master seemed to be "out of sync" (for want of a better word) with PRs
I didn't make time to track down the issue
Seems like I can't merge this, will merge the duplicate I have here: #16248 - it still references your commit though so should get attributed properly :) |
Thanks again for contributing! :D |
Problem
Fixes #15554 . Create static cohort from lifecycle insight using persons modal
This page mentions create cohort using this feature - https://posthog.com/docs/product-analytics/lifecycle
Changes
Added LifecycleActors and LifecycleFilter classes. Used in api/cohort.py::insert_cohort_actors_into_ch
👉 Stay up-to-date with PostHog coding conventions for a smoother review.
How did you test this code?
Manually creating cohorts in lifecycle insight
Added tests