Repository navigation
fix(frontend): share the 730-hour month for hourly cost conversions - #1446
Conversation
The Opportunities cost-period selector converted monthly to hourly with 1/720 while savings history, the RI exchange confirm and the backend (ricost.HoursPerMonth) all use 730, so hourly figures were about 1.4% higher than the backend-derived monthly ones. One exported HOURS_PER_MONTH in lib/hours-per-month.ts now feeds all three frontend call sites, and the savings-history comment no longer claims 365.25 days. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reached
This review includes 6 billable files and costs up to $1.50. Or wait 59 minutes for your next included review. View limit details
Comment |
|
Independent review (IAmJSD's agent, fresh context, given only the diff, the issue and the PR text): VERDICT: APPROVE Blocking:
Non-blocking:
Attacked:
Body-stale:
Reviewer: rD1. Bar while the maintainers are away (set by IAmJSD as acting owner): one approving independent review on the head, two for money, auth and security paths. |
|
Local verification at |
|
Merged by IAmJSD's agent at IAmJSD's request (IAmJSD is acting owner while the maintainers are away), under the bar IAmJSD set: 1 approving independent review(s) on |
Closes #337
Closes #394
Why
The Opportunities cost-period selector turned monthly costs into hourly ones with
1 / 720(a 30-day month). Savings history, the RI exchange confirm and the backend (ricost.HoursPerMonth, AWS's 365 * 24 / 12 = 730) all use 730. So hourly figures on Opportunities came out about 1.4% higher than the monthly figures the API derives. Both issues ask for one shared constant.Everything else on these issues was already on
main:internal/ricost, with a namedHoursPerMonthconstant.invalidateQuote(), the marketplace note prints a rounded5%, and a persistentalready_runningis non-200 (internal/server/task_lock.go). Only item 2 (this change) was left.What
frontend/src/lib/hours-per-month.tsexportsHOURS_PER_MONTH = 730. Its comment points toricost.HoursPerMonthso the two stay in sync.recommendations.ts: the hourly factor is now1 / HOURS_PER_MONTH. Daily stays1 / 30(left unchanged on purpose, see below).modules/savings-history.tsandriexchange-confirm.tsimport the shared constant instead of defining their own. The savings-history comment no longer says365.25 * 24 / 12.scaleCost(730, 'hourly')is 1, the 720/month row shows$0.9863, and2,000,000/moshows$2,739.7260/hr.For the owner to decide: daily still divides by 30, so hourly × 24 is about 1.4% below the daily figure. Deriving daily from 730 (24 / 730) would make the two agree, but it changes every daily figure and several daily tests. It is left out to keep this PR to the conversion the issues name.
Verification
main'srecommendations.tsand the new tests,npx jest src/__tests__/recommendations.test.ts -t scaleCostgives 2 failed, 5 passed. With this change: 7 passed.npm run lint: 0 errors (141 warnings, all already on main).npm run typecheck: clean.npm run build: ok.npx jest --no-coverage: 171 suites, 4502 passed, 1 skipped.scripts/test-git-secrets-allowlist.sh: 183 PASS, 0 FAIL.🤖 Generated with Claude Code