From b044c7c9dc3f557adab9cf1d71174e4d033dc4f4 Mon Sep 17 00:00:00 2001 From: tree Date: Mon, 26 Feb 2024 03:00:29 +0100 Subject: [PATCH] leaderboard statistics --- src/pages/leaderboard.astro | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/pages/leaderboard.astro b/src/pages/leaderboard.astro index 8916441..e84fee3 100644 --- a/src/pages/leaderboard.astro +++ b/src/pages/leaderboard.astro @@ -21,6 +21,12 @@ function getPoint (num){ 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; +}; + --- @@ -66,6 +72,17 @@ function getPoint (num){
+
+
{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 => (