Skip to content

fix(pricing): bill whole Beijing weekends off-peak for DeepSeek V4 - #505

Merged
xiufengsun merged 1 commit into
xiufengsun:mainfrom
xyzs996:deepseek-beijing-weekend-off-peak
Aug 22, 2026
Merged

xiufengsun merged 1 commit into
xiufengsun:mainfrom
xyzs996:deepseek-beijing-weekend-off-peak

Conversation

@xyzs996

@xyzs996 xyzs996 commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

What's wrong

The derived DeepSeek tier — isDeepSeekOffPeak in src/lib/pricing/index.js,
and the hand-copied getRowPricing in all five edge patches — decides from the
UTC hour alone. DeepSeek's pricing page now says:

Effective 00:00 (Beijing Time) on Sunday, August 23, 2026, we will adjust our
peak/off-peak billing rules … with off-peak rates applying throughout the day
on weekends (Saturdays and Sundays, Beijing Time)

That instant is 2026-08-22T16:00Z — already past. So rows whose hour_start
falls in 01:00–04:00 or 06:00–10:00 UTC on a Beijing Saturday or Sunday are
still 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_tier still wins, unchanged — this only touches the
derived path.

The part that is easy to get subtly wrong

The weekend is bounded in Beijing time, not UTC: 16:00Z Friday to
16:00Z Sunday. new Date(timestamp).getUTCDay() marks a different 48 hours, so
the instant is shifted by +08:00 first. China has had no daylight saving since
1991, 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 by
    isDeepSeekOffPeak before the hour check.
  • The five dashboard/edge-patches/*.ts — the same block, byte-identical, per
    the copy discipline in test/edge-pricing-parity.test.js.
  • test/pricing.test.js — seven assertions on computeRowCost inside the
    existing #491 test: a Beijing Saturday before the rule takes effect that
    must still be peak, the first Sunday window it flips, a Beijing Monday, a
    Friday, a later Saturday, and an explicit pricing_tier: "peak" that must
    still override.
  • test/edge-pricing-parity.test.js — asserts all five files carry the effective
    instant and the +08:00 shift, and adds a real byte-identical parity check
    on getRowPricing. That function was only substring-checked before, so one
    file's window could drift while every assertion still passed — the same failure
    mode the MODEL_PRICING parity test exists to catch.

Verification

node --test test/pricing.test.js test/edge-pricing-parity.test.js
# 54 pass, 0 fail

Full npm test is 2328 tests / 2290 pass / 32 fail — identical with and
without this patch
(I checked by stashing). Those 32 are MODULE_NOT_FOUND and
TS2307 from an environment without npm install run; none are in the pricing
or edge-parity files.

Summary by CodeRabbit

  • New Features

    • DeepSeek V4 pricing now recognizes Beijing-local Saturdays and Sundays as off-peak starting August 23, 2026.
    • Weekend usage receives the existing 50% off-peak rate across dashboards, summaries, leaderboards, and account breakdowns.
    • Pricing correctly handles the UTC-to-Beijing time boundary while preserving explicit pricing tiers and weekday peak rules.
  • Tests

    • Added coverage for weekend pricing, boundary times, weekday peak periods, and pricing-tier precedence.
    • Added consistency checks to ensure pricing behavior matches across dashboard views.

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/
@xyzs996
xyzs996 requested a review from xiufengsun as a code owner August 22, 2026 21:28
@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown

Warning

Your free Security trial is over. An organization admin can activate billing to continue.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 01068e9d-b621-4152-810a-febf8d564c90

📥 Commits

Reviewing files that changed from the base of the PR and between f731b84 and 6b7f599.

📒 Files selected for processing (8)
  • dashboard/edge-patches/tokentracker-account-daily.ts
  • dashboard/edge-patches/tokentracker-account-model-breakdown.ts
  • dashboard/edge-patches/tokentracker-account-summary.ts
  • dashboard/edge-patches/tokentracker-leaderboard-profile.ts
  • dashboard/edge-patches/tokentracker-leaderboard-refresh.ts
  • src/lib/pricing/index.js
  • test/edge-pricing-parity.test.js
  • test/pricing.test.js

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.


📝 Walkthrough

Walkthrough

DeepSeek 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.

Changes

DeepSeek weekend pricing

Layer / File(s) Summary
Pricing logic and edge mirrors
src/lib/pricing/index.js, dashboard/edge-patches/tokentracker-account-daily.ts, dashboard/edge-patches/tokentracker-account-model-breakdown.ts, dashboard/edge-patches/tokentracker-account-summary.ts, dashboard/edge-patches/tokentracker-leaderboard-profile.ts, dashboard/edge-patches/tokentracker-leaderboard-refresh.ts
DeepSeek rows at or after the cutoff use Beijing-local weekday detection. Saturday and Sunday rows use the existing off-peak rate.
Pricing validation
test/pricing.test.js, test/edge-pricing-parity.test.js
Tests cover cutoff boundaries, weekday and weekend pricing, explicit pricing-tier precedence, and byte-identical getRowPricing implementations across edge mirrors.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Merge Risk: ⚪ Minimal · up to 6b7f5

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: xiufengsun

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 8 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main pricing change for DeepSeek V4 Beijing weekends.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@xiufengsun
xiufengsun merged commit 51dde2b into xiufengsun:main Aug 22, 2026
8 checks passed
@xyzs996

xyzs996 commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants