mirror of
https://github.com/Unleash/unleash.git
synced 2024-12-22 19:07:54 +01:00
feat: add created by in search results (#7285)
This commit is contained in:
parent
05b7f6f4d9
commit
1a6197660f
@ -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:
|
||||
row.user_name ||
|
||||
row.user_username ||
|
||||
row.user_email ||
|
||||
'unknown',
|
||||
imageUrl: row.user_image_url,
|
||||
},
|
||||
};
|
||||
if (featureLifecycleEnabled) {
|
||||
entry.lifecycle = row.latest_stage
|
||||
|
@ -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: 'user@getunleash.io' },
|
||||
},
|
||||
{
|
||||
name: 'my_feature_b',
|
||||
createdBy: { id: 1, name: 'user@getunleash.io' },
|
||||
},
|
||||
],
|
||||
total: 2,
|
||||
});
|
||||
});
|
||||
|
@ -177,6 +177,30 @@ export const featureSearchResponseSchema = {
|
||||
},
|
||||
},
|
||||
},
|
||||
createdBy: {
|
||||
type: 'object',
|
||||
description: 'User who created the feature flag',
|
||||
additionalProperties: false,
|
||||
required: ['id', 'name', 'imageUrl'],
|
||||
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: {
|
||||
|
@ -38,7 +38,7 @@ export const userSchema = {
|
||||
nullable: true,
|
||||
},
|
||||
imageUrl: {
|
||||
description: `URL used for the userprofile image`,
|
||||
description: `URL used for the user profile image`,
|
||||
type: 'string',
|
||||
example: 'https://example.com/242x200.png',
|
||||
},
|
||||
|
@ -247,6 +247,11 @@ export type IFeatureSearchOverview = Exclude<
|
||||
> & {
|
||||
dependencyType: 'parent' | 'child' | null;
|
||||
environments: FeatureSearchEnvironmentSchema[];
|
||||
createdBy: {
|
||||
id: number;
|
||||
name: string;
|
||||
imageUrl: string | null;
|
||||
};
|
||||
};
|
||||
|
||||
export interface IFeatureTypeCount {
|
||||
|
Loading…
Reference in New Issue
Block a user