--- import BaseLayout from '../layouts/base.astro'; import contributors from '../contributors.json'; const points = {} let i = 0; for (const c of contributors.items) { const key = `c:${c.contributions}` if (!points[key]) { points[key] = { arr: [c.login], start: i } } else { points[key].arr.push(c.login) } i++ } function getPoint (num){ const key = `c:${num}` const obj = points[key]; return `${obj.start+1}${obj.arr.length > 1 ? '-'+(obj.start+obj.arr.length) : ''}`; } const median = arr => { const mid = Math.floor(arr.length / 2), nums = [...arr].sort((a, b) => a - b); return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; }; ---
{contributors.items.map((contrib, i) => ( ))}
Contributor # Commits
{[getPoint(contrib.contributions)].map((r) => (
{r < 4 && {r === "1" && "🥇"} {r === "2" && "🥈"} {r === "3" && "🥉"} } {r}.
))}
{contrib.login} {contrib.contributions}
{contributors.items.reduce((a, b) => (a + b.contributions), 0)} total commits
{contributors.items.length} total contributors
{contributors.items.filter(c => c.contributions >= 2).length} contributors with >= 2 commits
{contributors.items.filter(c => c.contributions >= 5).length} contributors with >= 5 commits
{contributors.items.filter(c => c.contributions >= 10).length} contributors with >= 10 commits
{contributors.items.filter(c => c.contributions >= 50).length} contributors with >= 50 commits
{contributors.items.filter(c => c.contributions >= 100).length} contributors with >= 100 commits
Median {median(contributors.items.map(c => c.contributions))} commits per contributor
Average {(Math.round((contributors.items.reduce((a, b) => (a + b.contributions), 0) / contributors.items.length)*100)/100)} commits per contributor

Eligible repositories

{contributors.repos.map(repo => (
@{repo}
))}