Skip to content

Commit 9c5963f

Browse files
fix: Repo number count on Overview page
1 parent af28c0a commit 9c5963f

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
@@ -14,7 +14,7 @@ export function AppProvider({ children }) {
1414
const [loadMsg, setLoadMsg] = useState('')
1515
const [govLoading, setGovLoading] = useState(false)
1616
const [error, setError] = useState('')
17-
17+
const [totalRepo, setTotalRepo] = useState(0);
1818
const savePat = useCallback(token => {
1919
setPat(token)
2020
token ? localStorage.setItem('oe_pat', token) : localStorage.removeItem('oe_pat')
@@ -36,6 +36,13 @@ export function AppProvider({ children }) {
3636
reposPerOrg[org.login] = await fetchRepos(org.login, pat)
3737
}))
3838

39+
const total = Object.values(reposPerOrg).reduce(
40+
(sum, repos) => sum + repos.length,
41+
0
42+
);
43+
44+
setTotalRepo(total);
45+
3946
setLoadMsg('Fetching contributor data for top repositories...')
4047
const contribsPerRepo = {}
4148
for (const org of validOrgs) {
@@ -88,7 +95,7 @@ export function AppProvider({ children }) {
8895
return (
8996
<Ctx.Provider value={{
9097
pat, savePat, orgs, model, issuesData,
91-
rateLimit, loading, loadMsg, govLoading, error,
98+
rateLimit, loading, loadMsg, govLoading, error, totalRepo,
9299
explore, runAudit, setError,
93100
}}>
94101
{children}

src/pages/OverviewPage.jsx

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

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

@@ -101,10 +101,10 @@ export default function OverviewPage() {
101101

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

110110
{/* Language + top repos */}

0 commit comments

Comments
 (0)