diff --git a/src/lib/db/project-store.ts b/src/lib/db/project-store.ts index 250d409185ec..45ed15ab4dca 100644 --- a/src/lib/db/project-store.ts +++ b/src/lib/db/project-store.ts @@ -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) { @@ -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)[]; let groupByColumns = [ 'projects.id', 'project_settings.default_stickiness', 'project_settings.project_mode', + 'project_stats.avg_time_to_prod_current_window', ]; if (userId) { @@ -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, }; } diff --git a/src/lib/openapi/spec/project-schema.ts b/src/lib/openapi/spec/project-schema.ts index 01b2282c147c..11ae53342889 100644 --- a/src/lib/openapi/spec/project-schema.ts +++ b/src/lib/openapi/spec/project-schema.ts @@ -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; diff --git a/src/lib/types/model.ts b/src/lib/types/model.ts index 9543a3ea8d6e..be9c61be7db3 100644 --- a/src/lib/types/model.ts +++ b/src/lib/types/model.ts @@ -501,6 +501,7 @@ export interface IProjectWithCount extends IProject { potentiallyStaleFeatureCount: number; memberCount: number; favorite?: boolean; + avgTimeToProduction: number; } export interface IClientSegment { diff --git a/src/test/fixtures/fake-project-store.ts b/src/test/fixtures/fake-project-store.ts index c69aaa8de98a..59b10cccabc4 100644 --- a/src/test/fixtures/fake-project-store.ts +++ b/src/test/fixtures/fake-project-store.ts @@ -48,6 +48,7 @@ export default class FakeProjectStore implements IProjectStore { featureCount: 0, staleFeatureCount: 0, potentiallyStaleFeatureCount: 0, + avgTimeToProduction: 0, }; }); }