Skip to content

fix(web): color month heatmap from month-scoped hours; honest year loading state - #149

Open
0Pluto wants to merge 1 commit into
realchendahuang:mainfrom
0Pluto:fix/heatmap-historical-year-month
Open

0Pluto wants to merge 1 commit into
realchendahuang:mainfrom
0Pluto:fix/heatmap-historical-year-month

Conversation

@0Pluto

@0Pluto 0Pluto commented Sep 30, 2026

Copy link
Copy Markdown

Summary

Follow-up to #144. The year-view anchor fix already landed upstream (cf95b82), but two leftovers still let the today-anchored trailing-366-day window leak into navigated historical periods.

Month view: zero heat colors for historical months

MonthHorizonPureView colors cells from notesCountMap, which is built from the shared stats.activity trailing-366-day window anchored to today. monthHourlyQuery already fetches the exact navigated month (passed as hourlyData) but is only consumed for day quadrants. So navigating to any month outside the trailing window renders an all-zero heatmap, even though the correct monthly data is already in flight.

This aggregates the month-scoped hourly rows into per-day totals and uses them as the heat source; notesCountMap stays as an in-flight fallback only. The hourly reads still go through memo_hourly_counts and scale with active hours in the range, so this does not reintroduce the #142 full-scan cost.

Year view: misleading fallback while loading a historical year

Since cf95b82 the year query falls back to the shared stats.activity while loading. For a historical year that briefly paints the tail ~3 months with real data and everything else as zeroes — a flash of a misleading partial year. Falling back to [] renders a uniform "no records" colour until the year query resolves.

The week-view data-source gap noted in #144 is intentionally not touched here (separate change line).

Verification

  • tsc --noEmit (apps/web) passes
  • No existing component tests cover these views; change is UI-only and reuses existing queries (monthHourlyQuery, yearStatsQuery)
  • Verified on a personal instance with 4700+ imported memos spanning 2017–2025: navigating historical years/months renders correct heat colors

Refs #144

…period

Follow-up to realchendahuang#144: after the year view gained its own stats query anchored
to the navigated year, two leftovers still leak the today-anchored 366-day
window into historical periods.

1. Year view no longer falls back to stats.activity while the year query
   is loading. That array is anchored to today, so for a historical year
   it briefly painted the tail ~3 months with real data and everything
   else as zeroes - a misleading partial picture. An empty activity array
   renders a uniform "no records" colour until the request resolves.

2. Month view heat colors now come from the month-scoped hourly query
   (monthHourlyQuery, already used for day quadrants), aggregated into
   per-day totals. notesCountMap is built from the shared trailing-366-day
   stats and only covers the current window, so months older than that
   rendered all-zero; it stays as an in-flight fallback only.

The hourly/counter reads scale with active hours in the requested range,
not total memo count, so historical windows do not reintroduce the full
scan cost from realchendahuang#142.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant