Skip to content

Commit

Permalink
1-3093: round the project health (#8718)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
thomasheartman authored Nov 12, 2024
1 parent 20c5a6f commit a964868
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib/features/project-status/project-status-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class ProjectStatusService {
segments,
},
activityCountByDate,
averageHealth,
averageHealth: Math.round(averageHealth),
lifecycleSummary,
};
}
Expand Down
14 changes: 14 additions & 0 deletions src/lib/features/project-status/projects-status.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit a964868

Please sign in to comment.