From e2bab6cef7de8e9b817d8d02c7adbd96eacc75e1 Mon Sep 17 00:00:00 2001 From: Richard Harris Date: Sat, 4 May 2019 13:05:09 -0400 Subject: [PATCH] fix contributors script --- site/scripts/get-contributors.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/site/scripts/get-contributors.js b/site/scripts/get-contributors.js index a17f4e4055..fe642e10e7 100644 --- a/site/scripts/get-contributors.js +++ b/site/scripts/get-contributors.js @@ -5,15 +5,26 @@ const Jimp = require('jimp'); process.chdir(__dirname); +const base = `https://api.github.com/repos/sveltejs/svelte/contributors`; +const { GITHUB_CLIENT_ID, GITHUB_CLIENT_SECRET } = process.env; + const SIZE = 64; async function main() { - const res = await fetch(`https://api.github.com/repos/sveltejs/svelte/stats/contributors?client_id=${process.env.GITHUB_CLIENT_ID}&client_secret=${process.env.GITHUB_CLIENT_SECRET}`); - const contributors = await res.json(); + const contributors = []; + let page = 1; + + while (true) { + const res = await fetch(`${base}?client_id=${GITHUB_CLIENT_ID}&client_secret=${GITHUB_CLIENT_SECRET}&per_page=100&page=${page++}`); + const list = await res.json(); + + if (list.length === 0) break; + + contributors.push(...list); + } const authors = contributors - .sort((a, b) => b.total - a.total) - .map(({ author }) => author); + .sort((a, b) => b.contributions - a.contributions); const sprite = new Jimp(SIZE * authors.length, SIZE);