-
-
Notifications
You must be signed in to change notification settings - Fork 720
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add stale flag count to project status payload (#8751)
This PR adds stale flag count to the project status payload. This is useful for the project status page to show the number of stale flags in the project.
- Loading branch information
1 parent
b4e2d5d
commit 5d32d14
Showing
11 changed files
with
132 additions
and
12 deletions.
There are no files selected for viewing
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
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
9 changes: 9 additions & 0 deletions
9
...ures/project-status/project-stale-flags-read-model/fake-project-stale-flags-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,9 @@ | ||
import type { IProjectStaleFlagsReadModel } from './project-stale-flags-read-model-type'; | ||
|
||
export class FakeProjectStaleFlagsReadModel | ||
implements IProjectStaleFlagsReadModel | ||
{ | ||
async getStaleFlagCountForProject(): Promise<number> { | ||
return 0; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ures/project-status/project-stale-flags-read-model/project-stale-flags-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,3 @@ | ||
export interface IProjectStaleFlagsReadModel { | ||
getStaleFlagCountForProject: (projectId: string) => Promise<number>; | ||
} |
19 changes: 19 additions & 0 deletions
19
.../features/project-status/project-stale-flags-read-model/project-stale-flags-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,19 @@ | ||
import type { Db } from '../../../server-impl'; | ||
import type { IProjectStaleFlagsReadModel } from './project-stale-flags-read-model-type'; | ||
|
||
export class ProjectStaleFlagsReadModel implements IProjectStaleFlagsReadModel { | ||
constructor(private db: Db) {} | ||
|
||
async getStaleFlagCountForProject(projectId: string): Promise<number> { | ||
const result = await this.db('features') | ||
.count() | ||
.where({ project: projectId, archived: false }) | ||
.where((builder) => | ||
builder | ||
.orWhere({ stale: true }) | ||
.orWhere({ potentially_stale: true }), | ||
); | ||
|
||
return Number(result[0].count); | ||
} | ||
} |
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
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
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