Repository navigation
docs(gift): drop the phantom "dashboard" trigger from the module doc - #198
Merged
Merged
Conversation
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
The
src/gift.rsmodule header claimed the daily gift is lazily triggered bywallet / dashboard / settle, but/api/dashboardnever callsensure_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 endpointsrc/gateway.rs:249/:440- the forwarding balance prechecks (forward/forward_stream), which are the "settle" pathThere is no dashboard trigger. Runtime proof: the same
GET /api/dashboardreturns{"month":[],"net":-0.0,"series":[]}on a fresh user, but{"month":[{"pts":1.0,"type":"gift"}],"net":1.0,...}as soon asGET /api/wallethas 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 thenext time a call site is added or removed.
Related Issue
(none)
Changes
src/gift.rs: replace thewallet / dashboard / settletrigger roster with aninvariant that points at the call sites, and state that
/api/dashboardreflects analready-granted gift without triggering it
Tests
cargo test全部通过 (187 passed; 0 failed)cargo fmt --check通过behaviour touched (the suite stays at 187 green)
Checklist