From 7ae6bd52bc6accc3730a016529b0144f9b9b3b47 Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 2 Feb 2021 22:35:49 +0100 Subject: [PATCH] maybe final contributions number --- api/networks/github.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/api/networks/github.js b/api/networks/github.js index 5aa46f8..33fd137 100755 --- a/api/networks/github.js +++ b/api/networks/github.js @@ -12,20 +12,14 @@ const options = { } function getContributors(contributors) { - const totalArray = contributors - // filter out duplicate contribution objects based on author.login - .reduce((accumalator, current) => { - if ( - !accumalator.some((item) => item.author.login === current.author.login) - ) { - accumalator.push(current) - } - return accumalator - }, []) - .map((item) => item.total) + const filtered = contributors + // filter out duplicate contributions based on author.login + .filter( + (v, i, a) => a.findIndex((t) => t.author.login === v.author.login) === i + ) + .map((item) => item) - console.log(totalArray) - return arrSum(totalArray) + return filtered.length } //