From 577f7a28241915bc01e92f458099b43e5566a2b6 Mon Sep 17 00:00:00 2001 From: Fredrik Oseberg Date: Mon, 9 Aug 2021 14:55:54 +0200 Subject: [PATCH] fix: add overview --- .../{project-health.ts => health-report.ts} | 0 src/lib/services/project-health-service.ts | 21 ++- src/lib/types/model.ts | 131 ++++++++++++++++++ 3 files changed, 146 insertions(+), 6 deletions(-) rename src/lib/routes/admin-api/project/{project-health.ts => health-report.ts} (100%) diff --git a/src/lib/routes/admin-api/project/project-health.ts b/src/lib/routes/admin-api/project/health-report.ts similarity index 100% rename from src/lib/routes/admin-api/project/project-health.ts rename to src/lib/routes/admin-api/project/health-report.ts diff --git a/src/lib/services/project-health-service.ts b/src/lib/services/project-health-service.ts index 687a109aaa..7294a307bc 100644 --- a/src/lib/services/project-health-service.ts +++ b/src/lib/services/project-health-service.ts @@ -6,7 +6,6 @@ import { FeatureToggle, IFeatureOverview, IProjectHealthReport, - IProjectOverview, } from '../types/model'; import { MILLISECONDS_IN_DAY, @@ -55,12 +54,22 @@ export default class ProjectHealthService { projectId: string, ): Promise { //const overview = await this.getProjectOverview(projectId, false); - const features = await this.featureToggleStore.getFeatures(); + const features = await this.featureToggleStore.getFeatures({ + projectId, + }); + const overview = { + name: 'test', + description: '', + features: features, + members: 1, + }; return { - // ...overview, - potentiallyStaleCount: await this.potentiallyStaleCount(features), - activeCount: this.activeCount(features), - staleCount: this.staleCount(features), + ...overview, + potentiallyStaleCount: await this.potentiallyStaleCount( + overview.features, + ), + activeCount: this.activeCount(overview.features), + staleCount: this.staleCount(overview.features), }; } diff --git a/src/lib/types/model.ts b/src/lib/types/model.ts index 77612abdd0..a3b8cf5d33 100644 --- a/src/lib/types/model.ts +++ b/src/lib/types/model.ts @@ -1,3 +1,134 @@ +import { IFeatureStrategy } from '../db/feature-strategy-store'; + +export interface IConstraint { + contextName: string; + operator: string; + values: string[]; +} + +export interface IStrategyConfig { + id?: string; + name: string; + constraints: IConstraint[]; + parameters: Object; +} + +export interface FeatureToggleDTO { + name: string; + description?: string; + type?: string; + stale?: boolean; + archived?: boolean; + variants?: IVariant[]; + createdAt?: Date; +} +export interface FeatureToggle extends FeatureToggleDTO { + project: string; + lastSeenAt?: Date; + createdAt?: Date; +} + +export interface IFeatureToggleClient { + name: string; + description: string; + type: string; + project: string; + stale: boolean; + variants: IVariant[]; + enabled: boolean; + strategies: IStrategyConfig[]; +} + +export interface IFeatureEnvironmentInfo { + name: string; + environment: string; + enabled: boolean; + strategies: IFeatureStrategy[]; +} + +export interface FeatureToggleWithEnvironment extends FeatureToggle { + environments: IEnvironmentDetail[]; +} + +export interface IEnvironmentDetail extends IEnvironmentOverview { + strategies: IStrategyConfig[]; +} + +export interface IFeatureEnvironment { + environment: string; + featureName: string; + enabled: boolean; +} + +export interface IVariant { + name: string; + weight: number; + weightType: string; + payload: { + type: string; + value: string; + }; + stickiness: string; + overrides: { + contextName: string; + values: string[]; + }[]; +} + +export interface IEnvironment { + name: string; + displayName: string; +} + +export interface IEnvironmentOverview { + name: string; + displayName: string; + enabled: boolean; +} + +export interface IFeatureOverview { + name: string; + type: string; + stale: boolean; + createdAt: Date; + lastSeenAt: Date; + environments: IEnvironmentOverview[]; +} + +export interface IProjectOverview { + name: string; + description: string; + features: IFeatureOverview[]; + members: number; + version: number; + health: number; +} + +export interface IProjectHealthReport extends IProjectOverview { + staleCount: number; + potentiallyStaleCount: number; + activeCount: number; +} + export interface IProjectParam { projectId: string; } + +export interface IArchivedQuery { + archived: boolean; +} +export interface ITagQuery { + tagType: string; + tagValue: string; +} +export interface IFeatureToggleQuery { + tag?: string[][]; + project?: string[]; + namePrefix?: string; + environment?: string; +} + +export interface ITag { + value: string; + type: string; +}