Skip to content

fix(dashboard): Home 'All' range toggle truncates history at 365 days but is labeled 'All' #52

Description

@cristim

Symptom

The savings-over-time chart on the Home page has a button labeled "All" in the range toggle (alongside 7d, 30d, 90d). After LeanerCloud/cloud-commitments-cli#1257, clicking "All" sends a rolling 365-day window to the backend, not all data ever.

For accounts whose first purchase is older than 365 days, the chart will silently truncate the leftmost slice of history and the user cannot tell that earlier purchases exist. The button label promises more data than is shown.

Root cause

The backend /api/history/analytics handler caps end - start at 366 days for DoS protection (internal/api/handler_analytics.go:309-315, issue LeanerCloud/cloud-commitments-cli#414). LeanerCloud/cloud-commitments-cli#1257 fixed the immediate 400 from sending 1970-01-01 by clamping the frontend to now - 365d, but did not address the label/UX gap.

This is a tradeoff inherited from the cap, not a bug introduced by LeanerCloud/cloud-commitments-cli#1257 -- the cap predates "All" working. Filed as a follow-up rather than expanding the scope of the QA 3.1 fix.

Fix options (pick one)

  1. Rename the button to 1y to match what it actually returns. Smallest blast radius; consistent with 7d / 30d / 90d. Tooltip/aria label can still mention "Last 365 days".
  2. Multi-window fetch: when "All" is selected, paginate over [end-365d, end], [end-730d, end-365d], ... until an empty page comes back, then merge. Higher implementation cost, but actually shows all history. Backend cap unchanged.
  3. Backend exception for /history/analytics cumulative endpoint: relax the 366-day cap only for the cumulative-savings query (which scans an indexed purchases table, not the per-bucket aggregate). Requires a separate DoS bound (row count, query timeout).

Option 1 is the smallest fix and likely the right one unless product wants the full-history view back.

Acceptance

  • A user with purchase history older than 365 days can see all of it on the Home chart (option 2/3), OR the toggle button no longer claims "All" when it means "last 365 days" (option 1).
  • Choice is documented in the chart spec / QA notes.

Discovered via

Adversarial review of LeanerCloud/cloud-commitments-cli#1257 (commit 8008bc0).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions