Skip to content

Commit

Permalink
feat: expose project time to production for project flag trends (#6068)
Browse files Browse the repository at this point in the history
  • Loading branch information
kwasniew authored Jan 30, 2024
1 parent 82e84ec commit 55b2bb4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lib/db/project-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ class ProjectStore implements IProjectStore {
'project_settings.project',
'projects.id',
)
.leftJoin('project_stats', 'project_stats.project', 'projects.id')
.orderBy('projects.name', 'asc');

if (query) {
Expand All @@ -148,12 +149,14 @@ class ProjectStore implements IProjectStore {
),
'project_settings.default_stickiness',
'project_settings.project_mode',
'project_stats.avg_time_to_prod_current_window',
] as (string | Raw<any>)[];

let groupByColumns = [
'projects.id',
'project_settings.default_stickiness',
'project_settings.project_mode',
'project_stats.avg_time_to_prod_current_window',
];

if (userId) {
Expand Down Expand Up @@ -214,6 +217,7 @@ class ProjectStore implements IProjectStore {
createdAt: row.created_at,
mode: row.project_mode || 'open',
defaultStickiness: row.default_stickiness || 'default',
avgTimeToProduction: row.avg_time_to_prod_current_window || 0,
};
}

Expand Down
6 changes: 6 additions & 0 deletions src/lib/openapi/spec/project-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ export const projectSchema = {
description:
'A default stickiness for the project affecting the default stickiness value for variants and Gradual Rollout strategy',
},
avgTimeToProduction: {
type: 'number',
example: 10,
description:
'The average time from when a feature was created to when it was enabled in the "production" environment during the current window',
},
},
components: {},
} as const;
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ export interface IProjectWithCount extends IProject {
potentiallyStaleFeatureCount: number;
memberCount: number;
favorite?: boolean;
avgTimeToProduction: number;
}

export interface IClientSegment {
Expand Down
1 change: 1 addition & 0 deletions src/test/fixtures/fake-project-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default class FakeProjectStore implements IProjectStore {
featureCount: 0,
staleFeatureCount: 0,
potentiallyStaleFeatureCount: 0,
avgTimeToProduction: 0,
};
});
}
Expand Down

0 comments on commit 55b2bb4

Please sign in to comment.