Skip to content

Commit

Permalink
fix HUGE BUG: getQuantile with byteWeight is now compute with the goo…
Browse files Browse the repository at this point in the history
…d unit #minor
  • Loading branch information
AlexTraveylan committed Jan 8, 2025
1 parent 0386946 commit 4ff7862
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions lib/eco-index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ describe("EcoIndexCalculator-HP", () => {

it("should have the correct score", () => {
const ecoIndex = calculator.getEcoIndex()
expect(ecoIndex.score).toBe(45)
expect(ecoIndex.score).toBe(53)
})

it("should have the correct gCo2e", () => {
const ecoIndex = calculator.getEcoIndex()
expect(ecoIndex.gCo2e).toBe(2.1)
expect(ecoIndex.gCo2e).toBe(1.94)
})

it("should have the correct water", () => {
const ecoIndex = calculator.getEcoIndex()
expect(ecoIndex.water).toBe(3.15)
expect(ecoIndex.water).toBe(2.91)
})

it("should have the correct grade", () => {
Expand Down
2 changes: 1 addition & 1 deletion lib/eco-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class EcoIndexCalculator {

const domScore = getQuantile(quantilesDom, this.metrics.dom)
const reqScore = getQuantile(quantilesReq, this.metrics.requests.total)
const sizeScore = getQuantile(quantilesSize, this.metrics.byteWeight.total)
const sizeScore = getQuantile(quantilesSize, this.metrics.byteWeight.total / 1000)

this.score = Math.round(100 - (5 * (3 * domScore + 2 * reqScore + sizeScore)) / 6)

Expand Down

0 comments on commit 4ff7862

Please sign in to comment.