feat: 标签详情页支持按月/年/全部时间维度筛选统计 (#461) - #463
Open
TNT-Likely wants to merge 1 commit into
Open
Conversation
- getTagStats / watchTransactionsByTag 增加可选 [start, end) 半开区间过滤, 共享账本 synthetic tag 分支同步支持 - 标签详情页 header 底部新增 月/年/全部 胶囊切换 + 周期选择器(轮盘), 周期口径与洞察页一致(periodForLabel/yearRangeFor,支持自定义每月起始日); 默认「全部」保持旧行为,统计卡片与交易列表共用同一范围 - watchTransactionsByTag 改用 drift join 全字段映射,修复旧手写映射漏掉 currencyCode/nativeAmount/categorySyncIdOverride 导致外币交易显示错误的隐患 - 页面统计/交易 provider 改 autoDispose,切换周期后旧范围的 watch 订阅及时释放
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.
Closes #461
需求
标签详情页目前只能看到该标签下所有历史数据的总和(会统计到 20 年前),无法像「洞察」页那样按时间维度分析近期开销。本 PR 为标签详情页增加 月 / 年 / 全部 三档时间筛选,统计卡片与关联交易列表共用同一范围。
方案
Repository 层
getTagStats/watchTransactionsByTag增加可选start/end参数,半开区间[start, end),不传 = 全部历史(现有调用方零改动)页面层
CapsuleSwitcher(月/年/全部,复用洞察页 l10n,零新增 key);月/年视角显示可点的周期标签,弹与洞察页一致的轮盘选择器periodForLabel/yearRangeFor,支持自定义每月起始日autoDispose:family 参数含时间范围,切换周期后旧范围的 drift watch 订阅及时释放设计决策(可讨论)
watchTransactionsByTag手写 SQL 映射漏掉currencyCode/nativeAmount/categorySyncIdOverride等列,外币交易在标签详情列表会显示原币金额而非折算金额;改为 drift join +readTable全字段映射,并补了回归测试测试
test/repositories/tag_stats_range_test.dart(7 测):范围边界(含 start 不含 end)、无范围回归、excludeFromStats 口径、ledgerId 组合、字段映射回归、共享 synthetic tag 范围过滤test/widgets/tag_detail_scope_filter_test.dart:默认全部 → 切月 → 切年 → 切回全部,统计与列表笔数逐一断言flutter test:647 passed;flutter analyze改动文件零告警真机验证(iOS 模拟器 iPhone 16 Pro Max,真实字体渲染)
造数:本月 2 支出 1 收入 + 今年 3 月 1 笔 + 2006 年 1 笔,全部挂「旅行」标签
胶囊 + 周期标签一行排布无溢出;「全部」视角不显示周期标签。Android 端未实测(同一套 Flutter 布局,组件均为现有组件)。