fix(dashboard): link to the year in review only when included accounts have data

Open
#721 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
58/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
next.js, playwright, react, supabase, typescript

Research direction

Start with src/lib/data/year-review.ts and compare hasYearData with the included-account filtering in src/lib/public-metrics/supabase-store.ts; then read the year-review section of docs/architecture/public-metrics.md. Update the dashboard link rule, document it, and cover excluded-account and include-it-again behavior in e2e/year-in-review.spec.ts. Done means only rows the year page counts make the link appear, with both database reads measured and their plans and times recorded in the pull request.

Written by the indexing model from the issue text.

Description

area: dashboard bug impact: low priority: P3 size: S

Context

PR #718 (issue #704) shows the dashboard's year in review link once the workspace stores an activity event or usage snapshot dated in that year: hasYearData in src/lib/data/year-review.ts reads activity_events and usage_snapshots by workspace_id and date only. The year page counts something narrower. computeYearReview reads through createSupabaseMetricStore(supabase, workspaceId, null), which takes only the workspace's included accounts (src/lib/public-metrics/supabase-store.ts:57, .eq("included", true)), and its providers figure is "distinct providers with an included account connected before asOf" (src/lib/public-metrics/yearly.ts:104). When that is 0 the page says "No provider was connected in " (src/app/w/[workspace]/year/[year]/page.tsx:104).

So a workspace whose only data this year sits on excluded accounts gets the link, and the link opens a page that says nothing was connected. StackDash's own events (provider null, no account, such as stackdash.daily_summary, which enqueue_daily_summaries queues for every workspace with a connection that is not revoked) count toward the link too, and the year page does not count them either.

Found by the Fable review of PR #718 (round 1, review body), and kept out of that PR because #704 settles the link's rule in one sentence.

Reproduced on 02951a17 (branch 704-hide-year-review-without-data), Chromium, 1366 by 900, local Supabase, synthetic e2e workspace: one active GitHub connection whose only account is excluded (included = false) and one github.push event on it an hour ago.

The dashboard offers the link:

Dashboard of a workspace whose only account is excluded, with the "Your 2026 so far" button beside the Dashboard heading

The link opens a year page that says no provider was connected:

Year in review page for 2026 saying "No provider was connected in 2026 so far. Connect a provider to start counting."

Plan

  1. Decide the rule: the link shows once the year page would count something, meaning an event or snapshot of an included account dated in the year. StackDash's own events, which have no account, do not count.
  2. Change hasYearData to read only included accounts' rows. Either join through external_accounts (included = true), or read the included account ids first (as createSupabaseMetricStore does, bounded by ACCOUNTS_LIMIT) and filter external_account_id with in.
  3. Measure both reads with explain (analyze, buffers) as a member at about a million events, for a workspace with no included rows in the year and for one with rows, and record the plans and times in the function's comment. The current reads use activity_events_workspace_timeline_idx and usage_snapshots_workspace_date_idx (measured in PR #718). Keep each read on an index range scan.
  4. Update the year in review section of docs/architecture/public-metrics.md to state the narrower rule.

Acceptance criteria

  • A workspace whose only rows in the year belong to excluded accounts shows no year in review link on the dashboard.
  • A workspace with only StackDash's own events in the year (no account) shows no link.
  • Including the account brings the link back, and it opens a year page that counts that account.
  • Both reads are measured as a member at about a million events, and the plans and times are quoted in the pull request.
  • Playwright: e2e/year-in-review.spec.ts covers the excluded account case and the include-it-again case.

Files and areas

  • src/lib/data/year-review.ts (hasYearData)
  • src/app/w/[workspace]/dashboard/page.tsx (YearReviewLink, only if its inputs change)
  • docs/architecture/public-metrics.md
  • e2e/year-in-review.spec.ts

Non-goals: the year page and its "No provider was connected" state, the command palette's Year in review entry, latestCardYear, and where the link sits in the header.

Verification

  • npm run typecheck, npm run lint, npm test: pass.
  • safe-e2e.sh <worktree> <port> e2e/year-in-review.spec.ts e2e/dashboard.spec.ts: pass.
  • The plans from step 3, quoted in the pull request.

Branch: <issue-number>-<slug>, cut from main once PR #718 has merged.
Closes with a Closes #<issue-number> footer on the commit or pull request.

Model: anthropic/claude-opus-5-5 | Reasoning effort: not reported by the harness

Dominant language
TypeScript
Stars
13
Forks
2
Avg merge
5h 20m
Merged PRs (30d)
287

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from eddiejaoude/StackDash

All issues in eddiejaoude/StackDash

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.