1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-03-27 00:19:39 +01:00

feat: stale flags count per project ()

This commit is contained in:
Mateusz Kwasniewski 2024-01-26 12:04:43 +01:00 committed by GitHub
parent 6ee4d2724e
commit 9b281ca508
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 27 additions and 2 deletions

View File

@ -141,7 +141,10 @@ class ProjectStore implements IProjectStore {
let selectColumns = [
this.db.raw(
'projects.id, projects.name, projects.description, projects.health, projects.updated_at, projects.created_at, count(features.name) FILTER (WHERE features.archived_at is null) AS number_of_features',
'projects.id, projects.name, projects.description, projects.health, projects.updated_at, projects.created_at, ' +
'count(features.name) FILTER (WHERE features.archived_at is null) AS number_of_features, ' +
'count(features.name) FILTER (WHERE features.archived_at is null and features.stale IS TRUE) AS stale_feature_count, ' +
'count(features.name) FILTER (WHERE features.archived_at is null and features.potentially_stale IS TRUE) AS potentially_stale_feature_count',
),
'project_settings.default_stickiness',
'project_settings.project_mode',
@ -203,6 +206,9 @@ class ProjectStore implements IProjectStore {
health: row.health,
favorite: row.favorite,
featureCount: Number(row.number_of_features) || 0,
staleFeatureCount: Number(row.stale_feature_count) || 0,
potentiallyStaleFeatureCount:
Number(row.potentially_stale_feature_count) || 0,
memberCount: Number(row.number_of_users) || 0,
updatedAt: row.updated_at,
createdAt: row.created_at,

View File

@ -35,6 +35,17 @@ export const projectSchema = {
example: 10,
description: 'The number of features this project has',
},
staleFeatureCount: {
type: 'number',
example: 10,
description: 'The number of stale features this project has',
},
potentiallyStaleFeatureCount: {
type: 'number',
example: 10,
description:
'The number of potentially stale features this project has',
},
memberCount: {
type: 'number',
example: 4,

View File

@ -497,6 +497,8 @@ export interface ICustomRole extends IRole {
export interface IProjectWithCount extends IProject {
featureCount: number;
staleFeatureCount: number;
potentiallyStaleFeatureCount: number;
memberCount: number;
favorite?: boolean;
}

View File

@ -42,7 +42,13 @@ export default class FakeProjectStore implements IProjectStore {
async getProjectsWithCounts(): Promise<IProjectWithCount[]> {
return this.projects.map((project) => {
return { ...project, memberCount: 0, featureCount: 0 };
return {
...project,
memberCount: 0,
featureCount: 0,
staleFeatureCount: 0,
potentiallyStaleFeatureCount: 0,
};
});
}