Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions src/pages/AnalyticsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export default function AnalyticsPage() {
const [granularity, setGranularity] = useState('monthly')
const [selectedRepo, setSelectedRepo] = useState('All')

if (!model) return null

const repoNames = ['All', ...model.allRepos.slice(0, 12).map(r => r.name)]
const hasData = Object.keys(issuesData || {}).length > 0

const allIssues = useMemo(() => {
const arr = []
Object.values(issuesData || {}).forEach(issues => arr.push(...issues))
Expand All @@ -46,6 +41,10 @@ export default function AnalyticsPage() {
[filteredIssues, granularity]
)

if (!model) return null

const repoNames = ['All', ...model.allRepos.slice(0, 12).map(r => r.name)]
const hasData = Object.keys(issuesData || {}).length > 0
const hasSeries = series.length > 0

return (
Expand Down
14 changes: 8 additions & 6 deletions src/pages/ContributorsPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,10 @@ export default function ContributorsPage() {
document.removeEventListener('mousedown', handleClickOutside)
}, [])

if (!model) return null
const { contributors } = model
const navigate = useNavigate()
const contributors = model?.contributors ?? []

const busFactor = useMemo(() => computeBusFactor(contributors), [contributors])
const topActive = contributors.slice(0, 10).filter(c => c.freshness > 50).length
const freshPct = contributors.length ? Math.round(topActive / Math.min(10, contributors.length) * 100) : 0
const connectors = contributors.filter(c => c.isConnector)
const crossOrg = contributors.filter(c => c.isCrossOrg)

const filtered = useMemo(() =>
contributors.filter(c => !search || c.login.toLowerCase().includes(search.toLowerCase())),
Expand All @@ -60,6 +55,13 @@ export default function ContributorsPage() {
const { sorted, sortConfig, onSort } = useSortedData(filtered, 'totalContribs', 'desc')
const visible = sorted.slice(0, shown)

if (!model) return null

const topActive = contributors.slice(0, 10).filter(c => c.freshness > 50).length
const freshPct = contributors.length ? Math.round(topActive / Math.min(10, contributors.length) * 100) : 0
const connectors = contributors.filter(c => c.isConnector)
const crossOrg = contributors.filter(c => c.isCrossOrg)

const riskColor = r => r === 'critical' ? 'var(--red)' : r === 'high' ? 'var(--amber)' : 'var(--green)'
const riskBar = r => r === 'critical' ? '90%' : r === 'high' ? '60%' : '25%'

Expand Down
10 changes: 5 additions & 5 deletions src/pages/GovernancePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ export default function GovernancePage() {
const { model, issuesData, runAudit, govLoading } = useApp()
const [tab, setTab] = useState('dead')

if (!model) return null

const hasAudit = Object.keys(issuesData || {}).length > 0
const daysSince = d => Math.floor((Date.now() - new Date(d)) / 86_400_000)

// Flatten all issues and tag with repo/org
const allIssues = useMemo(() => {
const arr = []
Expand All @@ -29,6 +24,11 @@ export default function GovernancePage() {
return arr
}, [issuesData])

if (!model) return null

const hasAudit = Object.keys(issuesData || {}).length > 0
const daysSince = d => Math.floor((Date.now() - new Date(d)) / 86_400_000)

// Health check 1 — Dead Issues (>90 days open, not a PR)
const deadIssues = allIssues
.filter(i => !i.pull_request && daysSince(i.created_at) >= 90)
Expand Down
4 changes: 2 additions & 2 deletions src/pages/OverviewPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ const fmt = n => n > 999 ? (n / 1000).toFixed(1) + 'k' : String(n)
export default function OverviewPage() {
const { orgs, model } = useApp()
const navigate = useNavigate()
if (!model) return null

const [open, setOpen] = useState(false)
const infoRef = useRef(null)

Expand All @@ -28,6 +26,8 @@ export default function OverviewPage() {
}
}, [])

if (!model) return null

const { allRepos } = model
const isMulti = orgs.length > 1
const totalStars = allRepos.reduce((s, r) => s + r.stargazers_count, 0)
Expand Down
5 changes: 3 additions & 2 deletions src/pages/RepositoriesPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ export default function RepositoriesPage() {
}, [])

const navigate = useNavigate()
if (!model) return null
const { allRepos } = model
const allRepos = model?.allRepos ?? []

const langs = useMemo(() =>
['All', ...new Set(allRepos.map(r => r.language).filter(Boolean))].slice(0, 10),
Expand All @@ -54,6 +53,8 @@ export default function RepositoriesPage() {
const { sorted, sortConfig, onSort } = useSortedData(filtered, 'healthScore', 'desc')
const visible = sorted.slice(0, shown)

if (!model) return null

const TABLE_COLS = [
['name', 'Repository'],
['stargazers_count', 'Stars'],
Expand Down
Loading