-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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(feature flags): copy cohorts linked to a flag #18642
Conversation
…i-project-feature-flags
…Hog/posthog into multi-project-feature-flags
…Hog/posthog into multi-project-feature-flags
…i-project-feature-flags
Size Change: 0 B Total Size: 2.01 MB ℹ️ View Unchanged
|
📸 UI snapshots have been updated1 snapshot changes in total. 0 added, 1 modified, 0 deleted:
Triggered by this commit. |
…i-project-feature-flags
frontend/src/lib/components/CompareFilter/compareFilterLogic.ts
Outdated
Show resolved
Hide resolved
frontend/src/queries/nodes/InsightViz/insightDisplayConfigLogic.ts
Outdated
Show resolved
Hide resolved
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.
Almost there, good tests, good job!
Can we move the seen_cohort_cache
type change to a separate PR though, it's becoming a bit too big and this one's risky on its own, since it changes high volume endpoints
…i-project-feature-flags
…i-project-feature-flags
Problem
When copying a feature flag to another project, the copying fails if the linked cohort doesn't exist in the target project.
Changes
Before copying, create any missing cohorts in the destination project.
To check if the cohort exists in the destination project, we search for the first cohort that matches by name. While it's possible there could be multiple cohorts with the same name, the user should resolve these duplications manually anyway (perhaps worth showing a warning prompt in the UI).
I went through the trouble of sorting linked cohorts by their creation order (post-order DFS), only to realize that the current implementation already returns ids in their creation order. This is because cohort ids are auto-incrementing, and converting the
cohort_ids
set into a list sorts them in the ascending order, which is, in fact, the order we want.However, I'm unsure if this is something to be relied upon - perhaps there's an edge case I haven't thought of yet. That said, the current tests pass even when
sort_by_creation_order
is set toFalse
.How did you test this code?
API test, 👀