Skip to content

Commit e019717

Browse files
fix: Repo number count on Overview page
1 parent bea2f0c commit e019717

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

src/context/AppContext.jsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function AppProvider({ children }) {
5858

5959
return () => clearTimeout(timeout)
6060
}, [rateLimit])
61-
61+
const [totalRepo, setTotalRepo] = useState(0);
6262
const savePat = useCallback(token => {
6363
setPat(token)
6464
token ? localStorage.setItem('oe_pat', token) : localStorage.removeItem('oe_pat')
@@ -80,6 +80,13 @@ export function AppProvider({ children }) {
8080
reposPerOrg[org.login] = await fetchRepos(org.login, pat)
8181
}))
8282

83+
const total = Object.values(reposPerOrg).reduce(
84+
(sum, repos) => sum + repos.length,
85+
0
86+
);
87+
88+
setTotalRepo(total);
89+
8390
setLoadMsg('Fetching contributor data for top repositories...')
8491
const contribsPerRepo = {}
8592
for (const org of validOrgs) {
@@ -130,7 +137,7 @@ export function AppProvider({ children }) {
130137
return (
131138
<Ctx.Provider value={{
132139
pat, savePat, orgs, model, issuesData,
133-
rateLimit, loading, loadMsg, govLoading, error,
140+
rateLimit, loading, loadMsg, govLoading, error, totalRepo,
134141
explore, runAudit, setError,
135142
}}>
136143
{children}

src/pages/OverviewPage.jsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const LANG_COLORS = ['#22c55e', '#f5c518', '#3b82f6', '#ef4444', '#a855f7', '#f9
1111
const fmt = n => n > 999 ? (n / 1000).toFixed(1) + 'k' : String(n)
1212

1313
export default function OverviewPage() {
14-
const { orgs, model } = useApp()
14+
const { orgs, model, totalRepo } = useApp()
1515
const navigate = useNavigate()
1616
if (!model) return null
1717

@@ -103,10 +103,10 @@ export default function OverviewPage() {
103103

104104
{/* Stats */}
105105
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(4,1fr)', gap: 12, marginBottom: 24 }}>
106-
<StatCard label="Total Repos" value={allRepos.length.toLocaleString()} />
106+
<StatCard label="Total Repos" value={totalRepo.toLocaleString()} />
107107
<StatCard label="Total Stars" value={fmt(totalStars)} />
108108
<StatCard label="Total Forks" value={fmt(totalForks)} />
109-
<StatCard label="Active Repos" value={activeRepos} sub={`${Math.round(activeRepos / allRepos.length * 100)}% of total`} />
109+
<StatCard label="Active Repos" value={activeRepos} sub={`${Math.round(activeRepos / totalRepo * 100)}% of total`} />
110110
</div>
111111

112112
{/* Language + top repos */}

0 commit comments

Comments
 (0)