1
0
mirror of https://github.com/oceanprotocol/community-numbers.git synced 2024-12-23 01:29:49 +01:00

tinkering

This commit is contained in:
Matthias Kretschmann 2021-02-02 13:34:50 +01:00
parent e4b5f3b552
commit 477912857d
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 23 additions and 7 deletions

View File

@ -23,7 +23,8 @@ Endpoint: [`https://oceanprotocol-community.now.sh`](https://oceanprotocol-commu
{
"github": {
"stars": 1000,
"repos": 1000
"repos": 1000,
"contributors": 1000
},
"medium": {
"followers": 1000

View File

@ -24,16 +24,31 @@ export default async function fetchGitHubRepos() {
return null
}
const json = await response.json()
const numbers = json.map((item) => item.stargazers_count)
const stars = arrSum(numbers)
const repositories = json.length
const jsonRepos = await response.json()
const starsArray = []
const contribArray = []
jsonRepos.forEach(async (item) => {
starsArray.push(item.stargazers_count)
const responseContrib = await fetch(
`https://api.github.com/orgs/oceanprotocol/${item.name}/stats/contributors`,
options
)
const jsonContrib = await responseContrib.json()
contribArray.push(jsonContrib.total)
})
const stars = arrSum(starsArray)
const repositories = jsonRepos.length
const contributors = arrSum(contribArray)
log(
'✓ GitHub. ' +
`Total: ${repositories} public projects with a total of ${stars} stargazers. ` +
`Total: ${repositories} public projects with a total of ${stars} stargazers & ${contributors} contributors. ` +
`Elapsed: ${new Date() - start}ms`
)
return { stars, repositories }
return { stars, repositories, contributors }
}