mirror of
https://github.com/Unleash/unleash.git
synced 2025-04-15 01:16:22 +02:00
fix: Stop healthrating from including archived (#1128)
- Since the archived toggles are not visible in the health dashboard, including them in the health rating calculation makes for some really confusing dashboards. This PR makes sure we only include non-archived toggles when calculating health.
This commit is contained in:
parent
8f325caa4f
commit
c9ff3972e2
@ -129,6 +129,7 @@ export default class ProjectHealthService {
|
||||
async calculateHealthRating(project: IProject): Promise<number> {
|
||||
const toggles = await this.featureToggleStore.getAll({
|
||||
project: project.id,
|
||||
archived: false,
|
||||
});
|
||||
|
||||
const activeToggles = toggles.filter((feature) => !feature.stale);
|
||||
|
@ -97,7 +97,67 @@ test('Health rating endpoint yields stale, potentially stale and active count on
|
||||
expect(res.body.potentiallyStaleCount).toBe(0);
|
||||
});
|
||||
});
|
||||
test('Health rating endpoint does not include archived toggles when calculating potentially stale toggles', async () => {
|
||||
const project = {
|
||||
id: 'potentially-stale-archived',
|
||||
name: 'Health rating',
|
||||
description: 'Fancy',
|
||||
};
|
||||
await app.services.projectService.createProject(project, user);
|
||||
await app.request
|
||||
.post(`/api/admin/projects/${project.id}/features`)
|
||||
.send({
|
||||
name: 'potentially-stale-archive-fresh',
|
||||
description: 'new',
|
||||
stale: false,
|
||||
})
|
||||
.expect(201);
|
||||
await app.request
|
||||
.post(`/api/admin/projects/${project.id}/features`)
|
||||
.send({
|
||||
name: 'potentially-stale-archive-fresh-2',
|
||||
description: 'new too',
|
||||
stale: false,
|
||||
})
|
||||
.expect(201);
|
||||
await app.request
|
||||
.post(`/api/admin/projects/${project.id}/features`)
|
||||
.send({
|
||||
name: 'potentially-stale-archive-stale',
|
||||
description: 'stale',
|
||||
stale: true,
|
||||
})
|
||||
.expect(201);
|
||||
await app.request
|
||||
.post(`/api/admin/projects/${project.id}/features`)
|
||||
.send({
|
||||
name: 'potentially-archive-stale',
|
||||
description: 'Really Old',
|
||||
createdAt: new Date(2019, 5, 1),
|
||||
})
|
||||
.expect(201);
|
||||
await app.request
|
||||
.post(`/api/admin/projects/${project.id}/features`)
|
||||
.send({
|
||||
name: 'potentially-archive-stale-archived',
|
||||
description: 'Really Old',
|
||||
createdAt: new Date(2019, 5, 1),
|
||||
archived: true,
|
||||
})
|
||||
.expect(201);
|
||||
|
||||
await app.services.projectHealthService.setHealthRating();
|
||||
await app.request
|
||||
.get(`/api/admin/projects/${project.id}/health-report`)
|
||||
.expect(200)
|
||||
.expect('Content-Type', /json/)
|
||||
.expect((res) => {
|
||||
expect(res.body.health).toBe(50);
|
||||
expect(res.body.activeCount).toBe(3);
|
||||
expect(res.body.staleCount).toBe(1);
|
||||
expect(res.body.potentiallyStaleCount).toBe(1);
|
||||
});
|
||||
});
|
||||
test('Health rating endpoint correctly handles potentially stale toggles', async () => {
|
||||
const project = {
|
||||
id: 'potentially-stale',
|
||||
|
Loading…
Reference in New Issue
Block a user