-
-
Notifications
You must be signed in to change notification settings - Fork 730
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: exclude archived features in max reporting #7559
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,12 +7,23 @@ export class FeatureStrategiesReadModel implements IFeatureStrategiesReadModel { | |
constructor(db: Db) { | ||
this.db = db; | ||
} | ||
|
||
private activeStrategies() { | ||
return this.db('feature_strategies') | ||
.leftJoin( | ||
'features', | ||
'features.name', | ||
'feature_strategies.feature_name', | ||
) | ||
.where('features.archived_at', null); | ||
} | ||
|
||
async getMaxFeatureEnvironmentStrategies(): Promise<{ | ||
feature: string; | ||
environment: string; | ||
count: number; | ||
} | null> { | ||
const rows = await this.db('feature_strategies') | ||
const rows = await this.activeStrategies() | ||
.select('feature_name', 'environment') | ||
.count('id as strategy_count') | ||
.groupBy('feature_name', 'environment') | ||
|
@@ -32,7 +43,7 @@ export class FeatureStrategiesReadModel implements IFeatureStrategiesReadModel { | |
feature: string; | ||
count: number; | ||
} | null> { | ||
const rows = await this.db('feature_strategies') | ||
const rows = await this.activeStrategies() | ||
.select('feature_name') | ||
.count('id as strategy_count') | ||
.groupBy('feature_name') | ||
|
@@ -52,17 +63,17 @@ export class FeatureStrategiesReadModel implements IFeatureStrategiesReadModel { | |
environment: string; | ||
count: number; | ||
} | null> { | ||
const rows = await this.db('feature_strategies') | ||
const rows = await this.activeStrategies() | ||
.select( | ||
'feature_name', | ||
'environment', | ||
this.db.raw( | ||
"MAX(coalesce(jsonb_array_length(constraint_value->'values'), 0)) as max_values_count", | ||
), | ||
) | ||
.from( | ||
.crossJoin( | ||
this.db.raw( | ||
'feature_strategies, jsonb_array_elements(constraints) AS constraint_value', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this had to be rewritten to cross join after adding join to the feature table so that the syntax is correct |
||
`jsonb_array_elements(constraints) AS constraint_value`, | ||
), | ||
) | ||
.groupBy('feature_name', 'environment') | ||
|
@@ -77,12 +88,13 @@ export class FeatureStrategiesReadModel implements IFeatureStrategiesReadModel { | |
} | ||
: null; | ||
} | ||
|
||
async getMaxConstraintsPerStrategy(): Promise<{ | ||
feature: string; | ||
environment: string; | ||
count: number; | ||
} | null> { | ||
const rows = await this.db('feature_strategies') | ||
const rows = await this.activeStrategies() | ||
.select( | ||
'feature_name', | ||
'environment', | ||
|
This file contains 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
Oops, something went wrong.
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.
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 wonder: if a feature is archived and then revived, is
archived_at
set tonull
again? I know we've run into issues with this before, but I think that archived_at might have been the solution?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 tested this manually and reviving brings the feature back to the reported metrics
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 one test to show archived feature exclusion.