-
-
Notifications
You must be signed in to change notification settings - Fork 721
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: put project lifecycle read model in own directory + add fake (#…
…8700) This PR moves the project lifecycle summary to its own subdirectory and adds files for types (interface) and a fake implementation. It also adds a query for archived flags within the last 30 days taken from `getStatusUpdates` in `src/lib/features/project/project-service.ts` and maps the gathered data onto the expected structure. The expected types have also been adjusted to account for no data. Next step will be hooking it up to the project status service, adding schema, and exposing it in the controller.
- Loading branch information
1 parent
8f18c2b
commit f92441f
Showing
5 changed files
with
129 additions
and
60 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...res/project-status/project-lifecycle-read-model/createProjectLifecycleSummaryReadModel.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import type { Db, IUnleashConfig } from '../../../server-impl'; | ||
import FeatureToggleStore from '../../feature-toggle/feature-toggle-store'; | ||
import { FakeProjectLifecycleSummaryReadModel } from './fake-project-lifecycle-summary-read-model'; | ||
import type { IProjectLifecycleSummaryReadModel } from './project-lifecycle-read-model-type'; | ||
import { ProjectLifecycleSummaryReadModel } from './project-lifecycle-summary-read-model'; | ||
|
||
export const createProjectLifecycleSummaryReadModel = ( | ||
db: Db, | ||
config: IUnleashConfig, | ||
): IProjectLifecycleSummaryReadModel => { | ||
const { eventBus, getLogger, flagResolver } = config; | ||
const featureToggleStore = new FeatureToggleStore( | ||
db, | ||
eventBus, | ||
getLogger, | ||
flagResolver, | ||
); | ||
return new ProjectLifecycleSummaryReadModel(db, featureToggleStore); | ||
}; | ||
|
||
export const createFakeProjectLifecycleSummaryReadModel = | ||
(): IProjectLifecycleSummaryReadModel => { | ||
return new FakeProjectLifecycleSummaryReadModel(); | ||
}; |
25 changes: 25 additions & 0 deletions
25
.../project-status/project-lifecycle-read-model/fake-project-lifecycle-summary-read-model.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import type { | ||
IProjectLifecycleSummaryReadModel, | ||
ProjectLifecycleSummary, | ||
} from './project-lifecycle-read-model-type'; | ||
|
||
export class FakeProjectLifecycleSummaryReadModel | ||
implements IProjectLifecycleSummaryReadModel | ||
{ | ||
async getProjectLifecycleSummary(): Promise<ProjectLifecycleSummary> { | ||
const placeholderData = { | ||
averageDays: 0, | ||
currentFlags: 0, | ||
}; | ||
return { | ||
initial: placeholderData, | ||
preLive: placeholderData, | ||
live: placeholderData, | ||
completed: placeholderData, | ||
archived: { | ||
currentFlags: 0, | ||
last30Days: 0, | ||
}, | ||
}; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...features/project-status/project-lifecycle-read-model/project-lifecycle-read-model-type.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
export interface IProjectLifecycleSummaryReadModel { | ||
getProjectLifecycleSummary( | ||
projectId: string, | ||
): Promise<ProjectLifecycleSummary>; | ||
} | ||
|
||
type StageDataWithAverageDays = { | ||
averageDays: number | null; | ||
currentFlags: number; | ||
}; | ||
|
||
export type ProjectLifecycleSummary = { | ||
initial: StageDataWithAverageDays; | ||
preLive: StageDataWithAverageDays; | ||
live: StageDataWithAverageDays; | ||
completed: StageDataWithAverageDays; | ||
archived: { | ||
currentFlags: number; | ||
last30Days: number; | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters