Skip to content

docs(gift): drop the phantom "dashboard" trigger from the module doc - #198

Merged
argszero merged 1 commit into
mainfrom
fix/gift-trigger-doc
Sep 13, 2026
Merged

argszero merged 1 commit into
mainfrom
fix/gift-trigger-doc

Conversation

@argszero

Copy link
Copy Markdown
Owner

Summary

The src/gift.rs module header claimed the daily gift is lazily triggered by
wallet / dashboard / settle, but /api/dashboard never calls ensure_daily_gift -
it only reports what has already been recorded. This PR corrects the doc line so it
matches the code.

grep -rn ensure_daily_gift src/ shows the production call sites are exactly:

  • src/routes/wallet.rs:102 - the wallet endpoint
  • src/gateway.rs:249 / :440 - the forwarding balance prechecks (forward /
    forward_stream), which are the "settle" path

There is no dashboard trigger. Runtime proof: the same GET /api/dashboard returns
{"month":[],"net":-0.0,"series":[]} on a fresh user, but
{"month":[{"pts":1.0,"type":"gift"}],"net":1.0,...} as soon as GET /api/wallet
has run first - the same request answers differently depending on whether the wallet
endpoint was hit.

The code is the intent, not the bug: the author's own test comment
(src/routes/wallet.rs:682-686) says the gift is granted by the first wallet fetch,
i.e. the dashboard reflects rather than triggers. The doc line has been wrong since
the file was born (889532d).

The rewrite states an invariant plus a pointer ("the trigger sites are whatever calls
ensure_daily_gift") instead of enumerating callers, so it cannot silently rot the
next time a call site is added or removed.

Related Issue

(none)

Changes

  • src/gift.rs: replace the wallet / dashboard / settle trigger roster with an
    invariant that points at the call sites, and state that /api/dashboard reflects an
    already-granted gift without triggering it
  • 涉及配置/数据结构的改动已同步示例文件

Tests

  • cargo test 全部通过 (187 passed; 0 failed)
  • cargo fmt --check 通过
  • 新增/更新了单元测试(如适用) - not applicable: documentation-only change, no
    behaviour touched (the suite stays at 187 green)

Checklist

  • 分支命名符合约定(feat/ /fix/ /docs/ ...)
  • Commit message 使用 Conventional Commits 格式
  • 单一职责,改动最小化

The module header claimed the daily gift is lazily triggered by
"wallet / dashboard / settle", but `ensure_daily_gift` is only called from
`routes/wallet.rs` (the wallet endpoint) and `gateway.rs`'s forwarding
balance prechecks (the forward / forward_stream paths that lead to settle).
`/api/dashboard` never triggers it - it only reports whatever has already
been recorded.

Runtime proof: the same `GET /api/dashboard` returns
`{"month":[],"net":-0.0}` on a fresh user, but
`{"month":[{"pts":1.0,"type":"gift"}],"net":1.0}` once `GET /api/wallet`
has run first.

The author's own test comment (wallet.rs:682-686) states the gift is
triggered by the first wallet fetch, i.e. the dashboard reflects rather
than triggers. So the doc line, not the code, is wrong - and it has been
wrong since the file was born in 889532d.

Rewrite it as an invariant plus a pointer (the trigger sites are whatever
calls `ensure_daily_gift`) instead of a roster that rots the next time a
call site is added or removed.
@argszero
argszero merged commit 81df12d into main Sep 13, 2026
1 check passed
@argszero
argszero deleted the fix/gift-trigger-doc branch September 13, 2026 04:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant