1
0
mirror of https://github.com/oceanprotocol/community-numbers.git synced 2024-11-25 11:28:45 +01:00
community-numbers/api/networks/bounties.js

32 lines
771 B
JavaScript
Raw Normal View History

2020-06-16 11:12:27 +02:00
import fetch from 'node-fetch'
import { log, logError } from '../utils'
2019-05-14 20:52:48 +02:00
const getGitcoin = async () => {
2020-06-16 12:32:47 +02:00
const response = await fetch(
'https://gitcoin.co/api/v0.1/bounties/?&org=oceanprotocol'
)
2019-05-14 20:52:48 +02:00
2020-06-16 12:32:47 +02:00
if (response.status !== 200) {
logError(`Non-200 response code from Gitcoin: ${response.status}`)
return null
}
2019-05-14 20:52:48 +02:00
2020-06-16 12:32:47 +02:00
const total = await response.json()
const open = total.filter((item) => item.is_open === true)
2019-05-14 20:52:48 +02:00
2020-06-16 12:32:47 +02:00
return { total: total.length, open: open.length }
2019-05-14 20:52:48 +02:00
}
2020-06-16 11:12:27 +02:00
export default async function fetchBounties() {
2020-06-16 12:32:47 +02:00
const start = Date.now()
const { total, open } = await getGitcoin()
2019-05-14 20:52:48 +02:00
2020-06-16 12:32:47 +02:00
log(
2020-06-16 16:43:55 +02:00
'✓ Bounties. ' +
2020-06-16 12:32:47 +02:00
`Total: ${total} bounties. Open: ${open} bounties. ` +
`Elapsed: ${new Date() - start}ms`
)
2019-05-14 20:52:48 +02:00
2020-06-16 12:32:47 +02:00
return { open, total }
2019-05-14 20:52:48 +02:00
}