From 029beea800360f058772b13714924de52659dbd7 Mon Sep 17 00:00:00 2001 From: muditagrawal2007 Date: Sat, 24 Oct 2026 13:18:01 +0530 Subject: [PATCH] fix(analytics): label GitHub's combined open count and split it where audited GitHub's open_issues_count is open issues AND open pull requests, but OrgExplorer labelled it "Open Issues" in the Repository Explorer table, the CSV export and both health-score popovers, and fed it to the Health Score's Issue Health term as if it were issues alone. - add services/issueMetrics.js as the single place that models the quirk: it splits an already-fetched /issues payload into issues and pull requests and only reports a split that adds up to GitHub's own combined number - label the column and the CSV header "Open Issues & PRs" and show the exact split underneath the count for repositories the audit has already fetched - document the Issue Health term in agent.md and in both popovers as the combined open backlog, which is what it always measured - no extra API requests: the split reuses the audit payload already in cache --- agent.md | 19 +++ src/pages/OverviewPage.jsx | 4 +- src/pages/RepositoriesPage.jsx | 52 +++++-- src/pages/RepositoriesPage.test.jsx | 132 ++++++++++++++++++ src/services/analytics.exportReposCSV.test.js | 68 +++++++++ src/services/analytics.js | 34 ++++- src/services/issueMetrics.js | 100 +++++++++++++ src/services/issueMetrics.test.js | 132 ++++++++++++++++++ 8 files changed, 527 insertions(+), 14 deletions(-) create mode 100644 src/pages/RepositoriesPage.test.jsx create mode 100644 src/services/analytics.exportReposCSV.test.js create mode 100644 src/services/issueMetrics.js create mode 100644 src/services/issueMetrics.test.js diff --git a/agent.md b/agent.md index 183fda4e..9214e6cf 100644 --- a/agent.md +++ b/agent.md @@ -125,6 +125,25 @@ Note: if additional metrics exist in the codebase beyond this list, add them here with their formula reference — don't let an agent infer meaning from variable names alone. +### Health Score formula + +``` +score = round(activity * 0.4 + issueHealth * 0.3 + diversity * 0.3) +``` + +| Term | Weight | Source | +|---|---|---| +| Activity | 40% | `100 - days since pushed_at` | +| Issue Health | 30% | `100 - (open / (open + 10)) * 100` | +| Contributor Diversity | 30% | `min(100, contributorCount * 10)` | + +`open` is the repository's `open_issues_count`. That GitHub field is **not** an +issue count — it is open issues *and* open pull requests combined, because on +GitHub a pull request is also an issue. The Issue Health term therefore +measures the repository's combined open backlog. The UI labels it +"Open Issues & PRs" for exactly this reason, and `services/issueMetrics.js` +splits the count exactly for repositories that have been audited. + ## Stable Contracts Unless explicitly requested, do not change: diff --git a/src/pages/OverviewPage.jsx b/src/pages/OverviewPage.jsx index 7b2036d2..f6670758 100644 --- a/src/pages/OverviewPage.jsx +++ b/src/pages/OverviewPage.jsx @@ -294,7 +294,9 @@ export default function OverviewPage() { Activity (40%) – How recently the repository has been updated.
  • - Issue Health (30%) – Balance between open issues and maintenance. + Issue Health (30%) – Balance between open work and + maintenance. GitHub counts a pull request as an issue, so this term + counts open issues and open pull requests together.
  • Contributor Diversity (30%) – Number of active contributors. diff --git a/src/pages/RepositoriesPage.jsx b/src/pages/RepositoriesPage.jsx index b267b0f9..4704661d 100644 --- a/src/pages/RepositoriesPage.jsx +++ b/src/pages/RepositoriesPage.jsx @@ -5,6 +5,7 @@ import { useApp } from '../context/AppContext' import { C, Badge, HealthBar, SortTh, PageTitle, LoadMore } from '../components/UI' import { useSortedData } from '../hooks/useSortedData' import { exportReposCSV } from '../services/analytics' +import { computeOpenCounts, describeOpenCounts, OPEN_BACKLOG_LABEL } from '../services/issueMetrics' import EmptyStateCard from '../components/EmptyStateCard' import { useNavigate } from 'react-router-dom' import AnalysisBanner from '../components/AnalysisBanner' @@ -14,7 +15,7 @@ const ACTIVITY_CLASSIFICATIONS = ['All', 'Thriving', 'Active', 'Dormant', 'Hiber const ACTIVITY_COLORS = { Thriving: 'var(--green)', Active: 'var(--blue)', Dormant: 'var(--amber)', Hibernating: 'var(--red)' } export default function RepositoriesPage() { - const { model, isComplete, loading, runFullExplore } = useApp() + const { model, isComplete, loading, runFullExplore, issuesData } = useApp() const [search, setSearch] = useState('') const [activityClassification, setActivityClassification] = useState('All') const [lang, setLang] = useState('All Languages') @@ -55,6 +56,19 @@ export default function RepositoriesPage() { ['All Organizations', ...new Set(allRepos.map(r => r.orgLogin).filter(Boolean))], [allRepos]) + // GitHub's `open_issues_count` is open issues + open pull requests. The + // exact split is only known for repositories the governance audit has + // already fetched, so it is computed once per repository here rather than + // re-derived on every render of every row. + const openCountsByRepo = useMemo(() => { + const counts = {} + for (const repo of model?.totalRepos ?? []) { + const key = `${repo.orgLogin}/${repo.name}` + counts[key] = computeOpenCounts(repo, issuesData?.[key]) + } + return counts + }, [model, issuesData]) + useEffect(() => { setOrgFilter('All Organizations') setShown(20) @@ -78,7 +92,7 @@ export default function RepositoriesPage() { ['name', 'Repository'], ['stargazers_count', 'Stars'], ['forks_count', 'Forks'], - ['open_issues_count', 'Open Issues'], + ['open_issues_count', OPEN_BACKLOG_LABEL], ['healthScore', 'Health'], ['language', 'Language'], ['pushed_at', 'Repository Activity'], @@ -159,6 +173,13 @@ export default function RepositoriesPage() {
  • Contributor Diversity → 30%
  • +

    + GitHub counts a pull request as an issue, so {OPEN_BACKLOG_LABEL}{' '} + is one combined number. Issue Health measures that combined open + backlog — hover a value to see the split once the governance audit + has run. +

    + Activity Classification