1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-05-03 01:18:43 +02:00

1-3093: round the project health (#8718)

This PR rounds the average health score we show for a project. With
fractional numbers, it'd often overflow the graph. It also doesn't
really give you much extra info, so we can round it. The rounding is
then used both in the text, in the graph, and to calculate the graph
fill percentage.

Before:

![image](https://github.com/user-attachments/assets/8d0fea3d-411d-42fb-bd80-d2683a63cdf2)

After:

![image](https://github.com/user-attachments/assets/f5c51742-8a2c-4b1a-bca3-7e812b9a1072)
This commit is contained in:
Thomas Heartman 2024-11-12 14:44:29 +01:00 committed by GitHub
parent 20c5a6f7ce
commit a964868e00
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -72,7 +72,7 @@ export class ProjectStatusService {
segments,
},
activityCountByDate,
averageHealth,
averageHealth: Math.round(averageHealth),
lifecycleSummary,
};
}

View File

@ -69,6 +69,7 @@ afterAll(async () => {
beforeEach(async () => {
await db.stores.clientMetricsStoreV2.deleteAll();
await db.rawDatabase('flag_trends').delete();
});
test('project insights should return correct count for each day', async () => {
@ -257,6 +258,19 @@ test('project health should be correct average', async () => {
expect(body.averageHealth).toBe(40);
});
test('project health stats should round to nearest integer', async () => {
await insertHealthScore('2024-04', 6);
await insertHealthScore('2024-05', 5);
const { body } = await app.request
.get('/api/admin/projects/default/status')
.expect('Content-Type', /json/)
.expect(200);
expect(body.averageHealth).toBe(6);
});
test('project status contains lifecycle data', async () => {
const { body } = await app.request
.get('/api/admin/projects/default/status')