1
0
mirror of https://github.com/oceanprotocol/community-numbers.git synced 2024-09-28 03:58:40 +02:00
community-numbers/api/networks/bounties.js

30 lines
808 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 () => {
const response = await fetch('https://gitcoin.co/api/v0.1/bounties/?&org=oceanprotocol')
2019-05-14 20:52:48 +02:00
if (response.status !== 200) {
logError(`Non-200 response code from Gitcoin: ${response.status}`)
return null
}
const total = await response.json()
const open = total.filter((item) => item.is_open === true)
2019-05-14 20:52:48 +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() {
2019-05-14 20:52:48 +02:00
const start = Date.now()
const { total, open } = await getGitcoin()
2019-05-14 20:52:48 +02:00
log(
'Re-fetched bounties. ' +
`Total: ${total} bounties. Open: ${open} bounties. ` +
2019-05-14 20:52:48 +02:00
`Elapsed: ${new Date() - start}ms`
)
return { open, total }
2019-05-14 20:52:48 +02:00
}