-
-
Notifications
You must be signed in to change notification settings - Fork 740
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: add created by in search results #7285
Merged
Merged
Changes from all commits
Commits
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 |
---|---|---|
|
@@ -133,6 +133,11 @@ class FeatureSearchStore implements IFeatureSearchStore { | |
'ft.tag_value as tag_value', | ||
'ft.tag_type as tag_type', | ||
'segments.name as segment_name', | ||
'users.id as user_id', | ||
'users.name as user_name', | ||
'users.username as user_username', | ||
'users.email as user_email', | ||
'users.image_url as user_image_url', | ||
] as (string | Raw<any> | Knex.QueryBuilder)[]; | ||
|
||
const lastSeenQuery = 'last_seen_at_metrics.last_seen_at'; | ||
|
@@ -232,7 +237,12 @@ class FeatureSearchStore implements IFeatureSearchStore { | |
'=', | ||
'features.name', | ||
); | ||
}); | ||
}) | ||
.leftJoin( | ||
'users', | ||
'users.id', | ||
'features.created_by_user_id', | ||
); | ||
|
||
query.leftJoin('last_seen_at_metrics', function () { | ||
this.on( | ||
|
@@ -407,6 +417,15 @@ class FeatureSearchStore implements IFeatureSearchStore { | |
dependencyType: row.dependency, | ||
environments: [], | ||
segments: row.segment_name ? [row.segment_name] : [], | ||
createdBy: { | ||
id: Number(row.user_id), | ||
name: | ||
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. hiding fallback from the UI |
||
row.user_name || | ||
row.user_username || | ||
row.user_email || | ||
'unknown', | ||
imageUrl: row.user_image_url, | ||
}, | ||
}; | ||
if (featureLifecycleEnabled) { | ||
entry.lifecycle = row.latest_stage | ||
|
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 |
---|---|---|
|
@@ -172,7 +172,16 @@ test('should search matching features by name', async () => { | |
const { body } = await searchFeatures({ query: 'feature' }); | ||
|
||
expect(body).toMatchObject({ | ||
features: [{ name: 'my_feature_a' }, { name: 'my_feature_b' }], | ||
features: [ | ||
{ | ||
name: 'my_feature_a', | ||
createdBy: { id: 1, name: '[email protected]' }, | ||
}, | ||
{ | ||
name: 'my_feature_b', | ||
createdBy: { id: 1, name: '[email protected]' }, | ||
}, | ||
], | ||
total: 2, | ||
}); | ||
}); | ||
|
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 |
---|---|---|
|
@@ -177,6 +177,30 @@ export const featureSearchResponseSchema = { | |
}, | ||
}, | ||
}, | ||
createdBy: { | ||
type: 'object', | ||
description: 'User who created the feature flag', | ||
additionalProperties: false, | ||
required: ['id', 'name', 'imageUrl'], | ||
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. decided to go for nulls instead of null + undefined. All fields will always be provided |
||
properties: { | ||
id: { | ||
description: 'The user id', | ||
type: 'integer', | ||
example: 123, | ||
}, | ||
name: { | ||
description: 'Name of the user', | ||
type: 'string', | ||
example: 'User', | ||
}, | ||
imageUrl: { | ||
description: `URL used for the user profile image`, | ||
type: 'string', | ||
example: 'https://example.com/242x200.png', | ||
nullable: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
components: { | ||
schemas: { | ||
|
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
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
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'm very careful here to avoid duplicate names