Skip to content

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

@Dexterity104

Description

@Dexterity104

src/pages/HomePage.tsx calls useDashboardData('35d') on line 246. That hook (src/pages/dashboard/useDashboardData.ts) was built for the authenticated dashboard and returns nine fields. Tracing the destructure on line 246, only datasets and isLoading are read. Going further:

  • datasets.miners.data is used for buildTopMinerRows, medianMergeRate, and minerCount. Needed.
  • datasets.prs.data is used for buildActivityRows, countMergedPrsInWindow, and totalMergedPrsEver. Needed.
  • datasets.repos.data.length is the only thing read from the repos query (line 266). The same number is already returned by useStats().uniqueRepositories, which the page already calls on line 247.
  • datasets.issues.data is not referenced anywhere in HomePage.tsx. The useIssues() query inside useDashboardData runs purely for the authenticated dashboard.
  • kpis, overview, trendLabels, trendSeries, featuredWork, featuredContributors, featuredDiscoveryContributors are each computed via useMemo on every dataset change. None of them appear in HomePage's JSX.

Two practical effects on the public landing page:

  1. Two extra network requests fire on every first paint. useIssues() is never read on this page, and useReposAndWeights() only contributes a count that useStats() already returns.
  2. The three featured-* memos run their full pipelines whenever the dashboard cache changes, even though their outputs never reach the rendered tree.

Suggested direction:

  • Keep useDashboardData for DashboardPage.
  • Switch HomePage to direct calls for the data it actually needs: useAllMiners() plus useAllPrs() for the rows, and the existing useStats() for uniqueRepositories, totalLinesChanged, totalCommits, and totalIssues.
  • Drop the references to the unused fields so the dashboard hook remains lean for its primary caller.

Net effect: first paint on the public page issues two fewer requests, and the React tree stops paying for memo work whose result is never displayed.

Related

The dependency on useDashboardData was added when the landing page was rebuilt in #950 and #938. The currently open #971 / #970 polish copy and layout on the same page, but neither touches the data layer.

The closest sibling concern is #652 (refactor repository views to avoid global /prs overfetch), which scopes itself to RepositoryPRsTable, RepositoryStats, and RepositoryContributorsTable and explicitly leaves the landing page out of scope. The fix proposed here does not require the new repo-scoped hook from #652 to land first; the two are independent and both reduce blast radius from useAllPrs() and friends.

#347 (consolidate loading / error / empty states via QueryBoundary) is the broader cleanup of how data hooks are consumed across pages and is loosely adjacent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    refactorCode restructuring without behavior change

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions