-
-
Notifications
You must be signed in to change notification settings - Fork 734
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: exclude archived features in segments count #7886
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Manifest Files |
) | ||
.select([ | ||
...this.prefixColumns(), | ||
this.db.raw( |
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.
The COUNT functions are now wrapped with CASE statements. These CASE statements ensure that only non-archived features (where features.archived_at is NULL) are counted. If a feature is archived, the CASE returns NULL, which does not affect the count, effectively making it 0
@@ -145,6 +144,11 @@ export default class SegmentStore implements ISegmentStore { | |||
`${T.featureStrategies}.id`, | |||
`${T.featureStrategySegment}.feature_strategy_id`, | |||
) | |||
.leftJoin( |
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.
added a new join to get feature archived info
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.
I also tried the where clause just before groupBy instead of rewriting counts but it didn't work.
@@ -48,7 +48,7 @@ describe('usage counting', () => { | |||
await db.rawDatabase.table('change_requests').delete(); | |||
}); | |||
|
|||
test('segment usage in active CRs is counted iff we ask for it', async () => { | |||
test('segment usage in active CRs is counted if we ask for it', async () => { |
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.
This wasn't actually a typo, but shorthand for "if and only if", but maybe I should've written it out? 😅
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.
LG
About the changes
Exclude archived feature flags from the segment usage count calculations
Making sure this list count
matches this strategy values
Important files
Discussion points