Repository navigation
fix(pricing): bill whole Beijing weekends off-peak for DeepSeek V4 - #505
Conversation
The derived tier looked at the UTC hour alone, so from 2026-08-22T16:00Z rows in 01:00-04:00 and 06:00-10:00 UTC on Beijing Saturdays and Sundays were priced at peak, where DeepSeek now bills off-peak all day. Off-peak is half of peak, so those rows read 2x in every account and leaderboard view. The weekend is bounded in Beijing time (16:00Z Friday to 16:00Z Sunday), so the instant is shifted by +08:00 before the weekday is read. An explicitly stored pricing_tier still wins. Ref: https://api-docs.deepseek.com/quick_start/pricing/
|
Warning Your free Security trial is over. An organization admin can activate billing to continue. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (8)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughDeepSeek pricing now treats Beijing-local Saturdays and Sundays as off-peak after the 2026-08-22 16:00 UTC cutoff. The canonical pricing logic and edge mirrors use the same UTC+08:00 conversion. Tests cover boundary behavior, precedence, and implementation parity. ChangesDeepSeek weekend pricing
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to This localized pricing change updates derived DeepSeek weekend billing while preserving explicit tier overrides and adds focused parity coverage; no actionable merge-blocking risk remains beyond normal checks and review. Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Thanks for merging. One follow-up you might care about: I've been collecting how different projects model this rule, and TokenTracker is one of four I cite as getting the calendar axis right — the comment in your peak check is quoted verbatim, because it states the thing most implementations leave implicit: "The weekend is bounded in Beijing time, so it runs 16:00Z Friday to 16:00Z Sunday." That's here, alongside CC0 test vectors for the two instants where the two calendars disagree: https://github.com/xyzs996/deepseek-peak-offpeak-vectors — no action needed, just letting you know rather than citing you silently. |
What's wrong
The derived DeepSeek tier —
isDeepSeekOffPeakinsrc/lib/pricing/index.js,and the hand-copied
getRowPricingin all five edge patches — decides from theUTC hour alone. DeepSeek's pricing page now says:
That instant is 2026-08-22T16:00Z — already past. So rows whose
hour_startfalls in
01:00–04:00or06:00–10:00UTC on a Beijing Saturday or Sunday arestill priced at peak, while DeepSeek bills off-peak. Off-peak is exactly half, so
those hours read 2× — in account daily, summary, model breakdown, leaderboard
list and leaderboard profile alike.
The first window this gets wrong is 2026-08-23 01:00–04:00 UTC (Beijing
Sunday 09:00–12:00).
An explicitly stored
pricing_tierstill wins, unchanged — this only touches thederived path.
The part that is easy to get subtly wrong
The weekend is bounded in Beijing time, not UTC:
16:00Z Fridayto16:00Z Sunday.new Date(timestamp).getUTCDay()marks a different 48 hours, sothe instant is shifted by
+08:00first. China has had no daylight saving since1991, so the fixed offset is exact and needs no tz database.
To be straight about how much that costs today: nothing. The two peak windows sit
entirely outside the 16 hours where the two spellings disagree, so both currently
return the same tier. It is not a live bug — it is a trap that arms itself if the
windows ever move. I did it the right way round anyway and said so in the comment.
Changes
src/lib/pricing/index.js—isBeijingWeekendOffPeak, consulted byisDeepSeekOffPeakbefore the hour check.dashboard/edge-patches/*.ts— the same block, byte-identical, perthe copy discipline in
test/edge-pricing-parity.test.js.test/pricing.test.js— seven assertions oncomputeRowCostinside theexisting
#491test: a Beijing Saturday before the rule takes effect thatmust still be peak, the first Sunday window it flips, a Beijing Monday, a
Friday, a later Saturday, and an explicit
pricing_tier: "peak"that muststill override.
test/edge-pricing-parity.test.js— asserts all five files carry the effectiveinstant and the
+08:00shift, and adds a real byte-identical parity checkon
getRowPricing. That function was only substring-checked before, so onefile's window could drift while every assertion still passed — the same failure
mode the
MODEL_PRICINGparity test exists to catch.Verification
Full
npm testis 2328 tests / 2290 pass / 32 fail — identical with andwithout this patch (I checked by stashing). Those 32 are
MODULE_NOT_FOUNDandTS2307from an environment withoutnpm installrun; none are in the pricingor edge-parity files.
Summary by CodeRabbit
New Features
Tests