Skip to content

refactor: trim HomePage data layer to what the page actually renders#975

Open
cleanjunc wants to merge 2 commits intoentrius:testfrom
cleanjunc:homepage-direct-data-hooks
Open

refactor: trim HomePage data layer to what the page actually renders#975
cleanjunc wants to merge 2 commits intoentrius:testfrom
cleanjunc:homepage-direct-data-hooks

Conversation

@cleanjunc
Copy link
Copy Markdown
Contributor

@cleanjunc cleanjunc commented May 7, 2026

Summary

HomePage.tsx was calling useDashboardData('35d'), a hook built for the authenticated dashboard. Tracing the destructure, only datasets and isLoading were ever read, and even then datasets.issues.data was never referenced and datasets.repos.data.length was already covered by useStats().uniqueRepositories, which the page also calls. Six memo pipelines inside useDashboardData (kpis, overview, trendLabels, trendSeries, featuredWork, featuredContributors, featuredDiscoveryContributors) ran their full reductions on every dataset change for outputs that never reached HomePage's JSX.

This PR switches the landing page to direct hooks for the data it actually consumes:

  • useAllPrs() for the activity feed, the 35 day merge count, and lifetime merged PRs
  • useAllMiners() for the top miner rows, miner count, and median merge rate
  • useStats() (already used) now also supplies uniqueRepositories, replacing the count previously derived from useReposAndWeights()

useDashboardData stays untouched for DashboardPage, its only remaining caller. Module level EMPTY_PRS and EMPTY_MINERS constants keep useMemo dependency references stable before data lands, avoiding a needless recompute on the first data tick.

Net effect on first paint of the public page: two fewer network requests (/issues and /dash/repos), and three featured pipelines stop running on every dataset refetch.

Related Issues

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Screenshots

Not applicable. No visual change; the rendered tree is identical.

Checklist

  • New components are modularized/separated where sensible
  • Uses predefined theme (e.g. no hardcoded colors)
  • Responsive/mobile checked
  • Tested against the test API
  • npm run format and npm run lint:fix have been run
  • npm run build passes
  • Screenshots included for any UI/visual changes

@xiao-xiao-mao xiao-xiao-mao Bot added the refactor Code restructuring without behavior change label May 7, 2026
@cleanjunc
Copy link
Copy Markdown
Contributor Author

@e35ventura @anderdc Could you please review this PR? Thanks!

@anderdc
Copy link
Copy Markdown
Collaborator

anderdc commented May 9, 2026

Fix conflicts.

@cleanjunc
Copy link
Copy Markdown
Contributor Author

Hi @anderdc
I've fixed the conflicts. Could you please review again?
Thank you!

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

Labels

refactor Code restructuring without behavior change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Landing page calls two API hooks and runs three useMemo chains whose results it never reads

2 participants