1
0
mirror of https://github.com/oceanprotocol/webtasks synced 2025-01-08 21:04:03 +01:00

Merge pull request #25 from oceanprotocol/feature/bounties-all

get count of all bounties
This commit is contained in:
Matthias Kretschmann 2018-12-20 15:08:50 +01:00 committed by GitHub
commit fc226ba570
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 17 deletions

View File

@ -9,8 +9,6 @@
[![Build Status](https://travis-ci.com/oceanprotocol/webtasks.svg?token=3psqw6c8KMDqfdGQ2x6d&branch=master)](https://travis-ci.com/oceanprotocol/webtasks) [![Build Status](https://travis-ci.com/oceanprotocol/webtasks.svg?token=3psqw6c8KMDqfdGQ2x6d&branch=master)](https://travis-ci.com/oceanprotocol/webtasks)
[![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol) [![Greenkeeper badge](https://badges.greenkeeper.io/oceanprotocol/webtasks.svg)](https://greenkeeper.io/) [![js oceanprotocol](https://img.shields.io/badge/js-oceanprotocol-7b1173.svg)](https://github.com/oceanprotocol/eslint-config-oceanprotocol) [![Greenkeeper badge](https://badges.greenkeeper.io/oceanprotocol/webtasks.svg)](https://greenkeeper.io/)
## Table of Contents
- [Tasks](#tasks) - [Tasks](#tasks)
- [Medium](#medium) - [Medium](#medium)
- [YouTube](#youtube) - [YouTube](#youtube)
@ -97,12 +95,13 @@ https://TASK_URL/TASK_NAME/
**Response** **Response**
Response is structured by network and returns the count of open bounties: Response is structured by network and returns the count of open bounties, and a `total` number counting all active and completed bounties:
```json ```json
{ {
"gitcoin": 1, "gitcoin": 1,
"bountiesNetwork": 2 "bountiesNetwork": 2,
"total": 17
} }
``` ```

View File

@ -37,11 +37,25 @@ async function getBountiesNetwork() {
} }
} }
async function getTotal() {
try {
const response = await axios.get('https://api.bounties.network/bounty/?search=ocean%20protocol')
const allBounties = response.data
const data = { total: allBounties.count }
return data
} catch (error) {
console.error(`Error: ${error.reason}`) // eslint-disable-line no-console
}
}
server.get('/', async (req, res) => { server.get('/', async (req, res) => {
try { try {
const dataGitcoin = await getGitcoin() const dataGitcoin = await getGitcoin()
const dataBountiesNetwork = await getBountiesNetwork() const dataBountiesNetwork = await getBountiesNetwork()
const data = Object.assign(dataGitcoin, dataBountiesNetwork) const dataTotal = await getTotal()
const data = Object.assign(dataGitcoin, dataBountiesNetwork, dataTotal)
res.send(data) res.send(data)
} catch (error) { } catch (error) {