Skip to content

Commit

Permalink
1-3085: extract some types
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasheartman committed Nov 8, 2024
1 parent 3be60b8 commit be01d71
Showing 1 changed file with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,21 @@ type ProjectLifecycleSummary = {
};
};

type FlagsInStage = {
initial: number;
'pre-live': number;
live: number;
completed: number;
archived: number;
};

type AverageTimeInStage = {
initial: number | null;
'pre-live': number | null;
live: number | null;
completed: number | null;
};

export class ProjectLifecycleSummaryReadModel
implements IProjectLifecycleSummaryReadModel
{
Expand All @@ -37,12 +52,9 @@ export class ProjectLifecycleSummaryReadModel
this.db = db;
}

async getAverageTimeInEachStage(projectId: string): Promise<{
initial: number | null;
'pre-live': number | null;
live: number | null;
completed: number | null;
}> {
async getAverageTimeInEachStage(
projectId: string,
): Promise<AverageTimeInStage> {
const q = this.db
.with(
'stage_durations',
Expand Down Expand Up @@ -88,13 +100,7 @@ export class ProjectLifecycleSummaryReadModel
);
}

async getCurrentFlagsInEachStage(projectId: string): Promise<{
initial: number;
'pre-live': number;
live: number;
completed: number;
archived: number;
}> {
async getCurrentFlagsInEachStage(projectId: string): Promise<FlagsInStage> {
const query = this.db('feature_lifecycles as fl')
.innerJoin('features as f', 'fl.feature', 'f.name')
.where('f.project', projectId)
Expand All @@ -116,7 +122,7 @@ export class ProjectLifecycleSummaryReadModel
completed: 0,
archived: 0,
},
);
) as FlagsInStage;
}

async getArchivedFlagsLast30Days(projectId: string): Promise<number> {
Expand Down

0 comments on commit be01d71

Please sign in to comment.