feat(wallet): transaction summary aggregation + daily gift ledger + net whitelist (rants 2026-08-22T00:04:21/00:07:08/06:34:37) - #114
Merged
Conversation
…ummary fix (rants 2026-08-22T00:04:21/00:07:08/06:34:37) - /api/transactions: response adds 'summary' — full SQL aggregation (not page-dependent), respects the type filter; income whitelist (earn/topup/gift) positive, consume negative; token totals (tokens/input/cached/output, input = tokens - cached - output) - type filter now accepts 'gift' - gift.rs ensure_daily_gift: writes a transactions row (type='gift') so the ledger matches the balance (was invisible before) - dashboard: net/series SQL whitelist fixed — topup/gift no longer counted as negative (only earn was positive before) - ui renderTxSummary: uses backend summary + shows token stats (Total/Input/Cached/Output, M/K format); type-based fallback instead of pts-sign based - i18n: tx.summary.tokens/input/cached/output zh+en - tests: +transactions_summary_and_dashboard_net_with_topup (summary + type filter + dashboard net), +gift_writes_transaction_record; updated wallet_summary_and_dashboard net to include the daily gift (+1) - 138/138 tests + fmt + clippy + node --check clean
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
Fix the transaction summary accounting + add full token statistics, per host rants
2026-08-22T00:04:21,2026-08-22T00:07:08and2026-08-22T06:34:37(project=aitokenpool). These three rants share the same root: income/expense classification and full-aggregation statistics.Backend:
GET /api/transactionsresponse now includessummary— full SQL aggregation (not page-dependent), respecting the currenttypefilter:earn/topup/gift(positive),consume= negative;input = tokens − cached − outputtypefilter now acceptsgifttransactionsrow (type='gift') ingift.rs ensure_daily_gift— the ledger finally matches the balance (previously invisible)06:34:37): onlyearnwas counted positive →topup(+2000) was subtracted as −2000. Nowearn/topup/giftpositive,consumenegative.Frontend:
renderTxSummaryuses the backendsummary(no longer local page-only sum); falls back to type-based classification (not pts-sign) when summary is absenttx.summary.tokens/input/cached/outputzh+enTests (138/138 + fmt + clippy + node --check clean):
transactions_summary_and_dashboard_net_with_topup: topup(+2000) + consume(0.5, 1000 tok, 200 cached, 100 out) + gift(+1) → income 2001 / expense 0.5 / net 2000.5; token sums;type=consumefilter scopes summary; dashboard net = 2000.5 (topup positive)gift_writes_transaction_record: gift grant writestype='gift'txwallet_summary_and_dashboardupdated: net now includes the daily gift (+1) since it's ledgeredRelated Issue
Host rants (project=aitokenpool), verbatim summaries:
2026-08-22T00:04:21— 交易记录汇总条错误:consume 被算进「总收入」+ 每日赠送不入账2026-08-22T00:07:08— 交易记录汇总条增加 Token 统计(后端 summary 全量聚合,与 00:04:21 一起实现)2026-08-22T06:34:37— 仪表盘「本月净变化」错误:topup 充值被当成负数扣减Changes
summaryaggregation (income/expense/net + 4 token fields), full-SQL, type-filter awareTests
cargo test— 138/138 passedcargo fmt --check— cleancargo clippy --all-targets -- -D warnings— cleannode --check ui/js/app.js— cleanChecklist
feat/tx-summary)