fix(statistics-deck): shell support for the period views #150
No reviewers
Labels
No labels
blocked
bug
enhancement
high-priority
low-priority
needs-info
needs-triage
ready-for-agent
ready-for-human
referenced
research
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gabogg/hikcentral!150
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/deck-shell-view-support"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
Reviewing the period-view PRs (#147 Month, #148 Week, #149 Day) surfaced gaps in the shell from #144 that every view hits:
loadDays.cyan, textprimaryanddim) thatcharts.jsdidn't resolve, so each re-read the tokens itself.API for views (
render(ctx))periodloadDays()loadPeriodDays(period)periodFor(start)/previousPeriod(){granularity, start, end}periods (endexclusive), built withperiodEnd/previousPeriodStartfromperiods.js. No need for the paged period list.createChart(canvas, config)createDeckChartwithoptions.localeset to the deck language; a view's ownlocalewins.localees-VE/en-US, forIntl.NumberFormat.currentDeckColors()/resolveDeckColors()also resolvedim,primaryandcyan.Adoption checklist for #147, #148 and #149
ctx.createChart(...)instead ofcreateDeckChart(ctx.Chart, ...)anddeckChartOptionsdirectly.previousDays, WeekdailyUrl) withctx.loadPeriodDays(ctx.previousPeriod())/ctx.periodFor(start).loadDaysrejection in the cell.Verification
pytestsuite passes.🤖 Generated with Claude Code
Code review: PR #150 (
fix/deck-shell-view-support@33cbe9bvs merge base08b6d1c)Small PR, both axes in one review pass. Standards: AGENTS.md,
code-standards.md,ui-design-guidelines.md, ADR 0002, and the Fowler smell baseline. Spec: the four problems in the PR description, which came from the #147 and #148 reviews, checked against how the three view PRs would adopt the new API.Standards
No hard violations. The hex fallbacks match the §2.1 tokens, and 39 tests pass.
loadDays: (other = period) => …: a default parameter only kicks in forundefined, soctx.loadDays(periods.find(...))on a miss silently returns the shown period's days as the "other" period. Make the other-period call explicit.LOCALES = { es, en }repeatsDECK_LANGS, so a new language would silently fall back to es-VE.surfacetoken.undefinedvsnullforloadDays. The locale test is shallow.Spec
ctxexposes neither the period list nor a previous-period helper, and the previous period may not be in the loaded (paged) list at all. Views would have to hand-build{granularity, start, end}against an undocumented contract.[], so views can't show "could not be loaded" (#148 S-7 depends on this).options.localeto every chart. Set it once, e.g. through a ctx-bound chart factory.Summary. Standards: 5 findings, worst S-1 (
loadDays(undefined)returns the wrong period). Spec: 3 findings, worst C-1/C-2 (no way to build the other period; failures look like no data). First pass, so all findings get fixed on this branch.🤖 Generated with Claude Code
Review fixes:
1c77ee1Every finding from the review is addressed.
ctx.loadDays()takes no argument and always loads the shown period;ctx.loadPeriodDays(period)is the explicit call for another period. Tested.DECK_LANGS = Object.keys(LOCALES), so one map drives both.surfacetoken is dropped.loadDays()calls, the explicit other-period call, rejection and retry, and the locale on real chart configs.periods.jsexportsperiodEnd,previousPeriodStartandperiodFor, mirroring the server's exclusive ends (month and year boundaries tested).ctx.periodFor(start)andctx.previousPeriod()return route-shaped{granularity, start, end}objects without the paged list.loadDaysrejects when the fetch fails and doesn't cache the failure. The detail panel already catches it and shows "could not be loaded"; views can now do the same. Tested (fail, then retry).ctx.createChart(canvas, config)wrapscreateDeckChartand setsoptions.localefrom the deck language, so views don't set it per chart. Tested in both languages.Verification: 43 deck tests pass (5 new); the full
pytestsuite passes.🤖 Generated with Claude Code
- ctx.loadDays() is the shown period only; ctx.loadPeriodDays(period) loads another one explicitly, so an undefined argument can no longer silently return the shown period's days. - ctx.periodFor(start) / ctx.previousPeriod() build route-shaped periods ({granularity, start, end exclusive}) with periodEnd/previousPeriodStart, without depending on the paged period list. - loadDays rejects when the fetch fails (not cached), so views can show "could not be loaded"; the detail panel already catches it. - ctx.createChart(canvas, config) sets the deck locale on every graph. - DECK_LANGS derives from the locale map; the unused `surface` token is dropped; the cache comment speaks of complete periods, not Closed Days. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>Code review, second pass: PR #150 (@
1c77ee1)All 8 first-pass findings (S-1–S-5, C-1–C-3) are verified fixed, with no regressions; 43/43 deck tests pass.
periodEnd/previousPeriodStartmatch the server's strategies, including the month and year edges. A view's ownoptions.localewins increateChart. There is no import cycle. EveryloadDayscaller handles the rejection.Standards
loadPeriodDays(undefined)threw synchronously (on afindmiss), escapingPromise.allSettled.ef77fc6. An exception to the P3-to-issue rule: the view PRs are adopting this API right now.periodFor/previousPeriodreadthis.granularityat call time.Spec
Summary. No P1. The one P2 is fixed; the remaining P3s are filed. Ready to merge on the maintainer's go.
🤖 Generated with Claude Code