feature flag optimizations part one#3145
Merged
Merged
Conversation
…DE_ALL, improved exposure saves
Contributor
There was a problem hiding this comment.
Pull request overview
This PR targets backend feature-flag performance by streamlining FeatureFlagService.getKeys() execution: it removes a per-request global-exclusion check, prevents irrelevant inclusion-segment data from being used for INCLUDE_ALL flags, and makes exposure recording a true fire-and-forget bulk insert with conflict ignore.
Changes:
- Removed global exclusion logic from
getKeys()to avoid repeated expensive checks per request. - Adjusted segment resolution inputs to ignore inclusion segments when
filterMode === INCLUDE_ALL. - Reworked exposure persistence to use a repository bulk insert with
orIgnore()and to avoid awaiting a transaction; added unit tests for the new behavior.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/backend/src/api/services/FeatureFlagService.ts | Removes global exclusion check, guards inclusion segment IDs for INCLUDE_ALL, and switches exposure recording to fire-and-forget via repository insert. |
| packages/backend/src/api/repositories/FeatureFlagExposureRepository.ts | Adds recordExposureIfNotExists() bulk insert using orIgnore() to avoid duplicate-write overhead. |
| packages/backend/test/unit/services/FeatureFlagService.test.ts | Adds unit coverage for removed global exclusion call, exposure recording behavior, and segment handling by filterMode. |
| packages/backend/test/unit/repositories/FeatureFlagExposureRepository.test.ts | Adds unit coverage asserting the repository insert path uses orIgnore() and correct values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
bcb37
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
handles 1a, 1b, and 4 from the research spike plan that claude and I spun up #3143
Removes global exclude logic from
getKeys()(if we can't do that, then we'll need to cache the global exclude lists, because it isn't happening currently so gets called every time... not a problem current asclcandmathia-student-uidon't have global exclude lists currently, but if someone added a big one today, it would cause problems)Guards against include-list data being used in segment lookups when INCLUDE_ALL (this is one part of a two part fix in another pr)
Fixes issues in exposure save:
.savebecause of how typeorm treats full object as param vs an id, however: