Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/review/review-effort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,10 @@ function bandForEffort(effort: number): 1 | 2 | 3 | 4 | 5 {
return 5;
}

/** Map a persisted minutes estimate back to its complexity band (inverse of `estimateReviewEffort`'s minutes step). */
/** Map a persisted rounded minutes estimate to the highest complexity band it could represent. */
export function bandFromMinutes(minutes: number): 1 | 2 | 3 | 4 | 5 {
return bandForEffort(Math.max(0, minutes) / MINUTES_PER_EFFORT);
const maxRepresentedEffort = (Math.max(0, minutes) + 0.5) / MINUTES_PER_EFFORT;
return bandForEffort(maxRepresentedEffort);
}

/** Estimate the review effort of a change set. Pure and deterministic. */
Expand Down
7 changes: 7 additions & 0 deletions test/unit/review-effort.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,11 @@ describe("bandFromMinutes (#2155)", () => {
expect(bandFromMinutes(sample.minutes)).toBe(sample.band);
}
});

it("keeps rounded boundary minutes in the higher possible band (regression for #2155)", () => {
expect(bandFromMinutes(5)).toBe(2);
expect(bandFromMinutes(20)).toBe(3);
expect(bandFromMinutes(60)).toBe(4);
expect(bandFromMinutes(150)).toBe(5);
});
});
4 changes: 4 additions & 0 deletions test/unit/stats.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,10 @@ describe("aggregateReviewEffort — maintainer complexity fold (#2155)", () => {
// minutes 4 -> band 1; minutes 96 -> band 4 -> rounded avg 3; total 100.
expect(aggregateReviewEffort([4, 96])).toEqual({ avgBand: 3, totalEstimatedMinutes: 100 });
});

it("keeps boundary-rounded minutes in the higher possible avgBand (regression for #2155)", () => {
expect(aggregateReviewEffort([5, 20, 60, 150])).toEqual({ avgBand: 4, totalEstimatedMinutes: 235 });
});
});

describe("computeStats — review-effort read is fail-safe", () => {
Expand Down