feat(Segment membership): Refresh membership counts on segment edit#7828
feat(Segment membership): Refresh membership counts on segment edit#7828khvn26 wants to merge 1 commit into
Conversation
Wire the per-project segment membership count refresh into the segment create, update, clone and LaunchDarkly import paths via a new `enqueue_membership_refresh` service, so edits refresh counts within minutes instead of waiting for the daily backfill. The service debounces per project and no-ops when the feature flag is off. beep boop
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
Docker builds report
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7828 +/- ##
=======================================
Coverage 98.58% 98.58%
=======================================
Files 1465 1466 +1
Lines 56889 56974 +85
=======================================
+ Hits 56082 56167 +85
Misses 807 807 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Playwright Test Results (oss - depot-ubuntu-latest-16)Details
Playwright Test Results (oss - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-arm-16)Details
Playwright Test Results (private-cloud - depot-ubuntu-latest-16)Details
|
Visual Regression19 screenshots compared. See report for details. |
emyller
left a comment
There was a problem hiding this comment.
I'd love to see suggested improvements to tests, though none are blocking if you need to proceed.
| url = reverse( | ||
| "api-v1:projects:project-segments-detail", | ||
| args=[project, segment], | ||
| ) | ||
| data = { | ||
| "name": "renamed", | ||
| "project": project, | ||
| "rules": [{"type": "ALL", "rules": [], "conditions": []}], | ||
| } | ||
|
|
||
| # When | ||
| response = admin_client.put( | ||
| url, data=json.dumps(data), content_type="application/json" | ||
| ) |
There was a problem hiding this comment.
| url = reverse( | |
| "api-v1:projects:project-segments-detail", | |
| args=[project, segment], | |
| ) | |
| data = { | |
| "name": "renamed", | |
| "project": project, | |
| "rules": [{"type": "ALL", "rules": [], "conditions": []}], | |
| } | |
| # When | |
| response = admin_client.put( | |
| url, data=json.dumps(data), content_type="application/json" | |
| ) | |
| # When | |
| response = admin_client.put( | |
| f"/api/v1/projects/{project}/segments/{segment}/", | |
| data={ | |
| "name": "renamed", | |
| "project": project, | |
| "rules": [{"type": "ALL", "rules": [], "conditions": []}], | |
| }, | |
| format="json", | |
| ) |
Similar improvements can be made throughout this patch.
| ) | ||
|
|
||
| # When | ||
| # the import (which bulk-creates segments) completes |
There was a problem hiding this comment.
| # the import (which bulk-creates segments) completes |
| process_import_request(import_request) | ||
|
|
||
| # Then | ||
| # it triggers a single membership refresh for the imported project |
There was a problem hiding this comment.
| # it triggers a single membership refresh for the imported project |
There was a problem hiding this comment.
Not sure if LLM-generated, but I don't see value in the extra GWT lore throughout this patch.
Thanks for submitting a PR! Please check the boxes below:
docs/if required so people know about the feature.Changes
Closes #7470.
In this PR, we wire the per-project segment membership count cache refresh into the segment edit paths. The daily backfill stays as the safety net for projects whose segments aren't edited.
A new
enqueue_membership_refresh(project)service queuesrefresh_project_segment_countsfor a project with a debounce to protect against rapid successive edits.It's called from each path that creates or edits a canonical segment:
SegmentSerializer.create)SegmentSerializer.update)cloneviewset action)process_import_requestcompletes)Segment deletion is left to the daily backfill, which prunes stale count rows.
How did you test this code?
Added new tests:
enqueue_membership_refreshcovering the flag gate, the per-project debounce, and that an enqueued refresh runs end to end.