Skip to content
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

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

kwasniew
Copy link
Contributor

@kwasniew kwasniew commented Aug 15, 2024

About the changes

Exclude archived feature flags from the segment usage count calculations

Making sure this list count
Screenshot 2024-08-15 at 10 09 36
matches this strategy values
Screenshot 2024-08-15 at 10 09 20

Important files

Discussion points

Copy link

vercel bot commented Aug 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Aug 15, 2024 9:29am
unleash-monorepo-frontend ⬜️ Ignored (Inspect) Visit Preview Aug 15, 2024 9:29am

Copy link
Contributor

github-actions bot commented Aug 15, 2024

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

)
.select([
...this.prefixColumns(),
this.db.raw(
Copy link
Contributor Author

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(
Copy link
Contributor Author

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

Copy link
Contributor Author

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 () => {
Copy link
Contributor

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? 😅

Copy link
Contributor

@sjaanus sjaanus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LG

@kwasniew kwasniew merged commit a89f051 into main Aug 15, 2024
7 checks passed
@kwasniew kwasniew deleted the exclude-archived-features-segment-count branch August 15, 2024 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants