Repository navigation
feat(overview): load statistics for any local date range - #4
Merged
AritxOnly merged 3 commits intoNov 3, 2026
Merged
Conversation
Platforms can offer custom ranges (for example Oct 12 to Dec 31) without reconstructing totals in UI. OverviewViewModel.loadRangeNow(start, endExclusive) returns OverviewRangeUiState: daily stats for every day, status distribution, completion periods, metrics compared with the preceding period of the same length, and completed task titles. It uses the same rules as the monthly projection (completions by completion date, other states by due date). The Apple bridge exposes loadRange with an error callback; ranges are limited to 1..3660 days.
This was referenced Nov 3, 2026
AritxOnly
approved these changes
Nov 3, 2026
AritxOnly
left a comment
Contributor
There was a problem hiding this comment.
Fixed completedTaskTitles to use actual completion dates. Added coverage for late completion, no due date, completion before the range, and the exclusive end boundary.
Validation: combined PR #1–#4 checkout with both follow-up fixes; ./gradlew --offline -PlifiMode=stub :shared:macosArm64Test — 280 tests passed, 0 failures. Private Lifi mode and iOS framework linking were not rerun in this pass.
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.
背景
各端的时间范围选择目前只能用 Core 的固定窗口(近 7 天、近 4 周、近 12 个月、150 天热力图)或整月(
loadMonthNow)。用户希望可以选任意起止日期,例如 10 月 12 日到 12 月 31 日。这类统计应该由 Core 计算,平台不重复实现。改动
OverviewViewModel.loadRangeNow(startDate, endDateExclusive):读取本地日期范围[start, endExclusive)的统计。buildRangeState与buildMonthState使用相同的规则:完成按实际完成日期,其他状态和各项指标按截止日期。IllegalArgumentException。OverviewRangeUiState,包含:每天的数据(范围内每一天,今天之后的日期没有完成记录)、状态分布、完成时间段、指标(OverviewMonthlyMetrics)、范围内完成的任务。IosOverviewStateBridge.loadRange(startDate, endDateExclusive, onState, onError):与loadMonth写法一致,错误通过onError返回,不会让应用退出。taskTimes,只在范围统计中使用;buildMonthState没有改动。测试
新增 3 个测试:
wholeMonthRangeMatchesMonthlyProjection:范围恰好是一整月时,结果与buildMonthState完全一致(状态分布、完成数、每日数据);完成时间段的合计等于完成数。customRangeSpansMonthsIntoTheFutureAndComparesWithPrecedingPeriod:10 月 12 日~12 月 31 日(81 天)跨月且延伸到未来。验证每日数据条数、完成数、状态分布、完成时间段、前一时段的任务数,以及范围内完成的任务。emptyOrReversedRangesAreRejected。验证
./gradlew -PlifiMode=stub :shared:macosArm64Test:277 个测试全部通过(原 274 + 新增 3)。./gradlew -PlifiMode=private :shared:macosArm64Test:331 个测试全部通过(原 328 + 新增 3)。影响
OverviewRangeUiState和loadRange。