You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AI code review — automated review for reference, author can ignore or act on any point.
Clean extraction, and the implementation is sound: using a fixed UTC+8 shift is correct here precisely because China has no DST, and getUTCDay() on the shifted date gives the true Beijing weekday. I also checked the midnight-straddle concern — within the two peak windows (UTC 01–04 → Beijing 09–12, UTC 06–10 → Beijing 14–18) the shifted date never crosses into a different calendar day than the UTC date, so there's no boundary case where hour and weekday disagree. The test table covering window start/end plus Sat/Sun/Monday in Beijing is exactly right.
Two points:
Holidays. If the provider's peak-pricing notice follows the usual convention of excluding weekends and Chinese public holidays (not just weekends), this suppresses peak only for Sat/Sun and will keep peak rates active during statutory holidays that fall on weekdays. Worth verifying against the exact terms the pricing was derived from — if holidays are excluded too, isPeakPricing needs a holiday table or at least a TODO acknowledging it.
Naming nit (packages/console/app/src/routes/zen/util/pricing.ts): the function answers "is this instant inside a weekday peak window", so something like isPeakWindow(date) might describe it more precisely than isPeakPricing. Purely cosmetic.
Also FYI for whoever merges first: this PR and #44306 both touch packages/console/app/src/routes/zen/util/handler.ts, though in different regions (import block + ~line 1049 vs ~line 911), so a trivial rebase may be needed depending on merge order.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tests
bun test test/pricing.test.tsbun typecheckbun test(12 pass; 2 pre-existing failures inproviderUsage.test.ts, where Google output usage is currently 5 but the fixture expects 3)Requested by: @MrMushrooooom (Jack via Slack)