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,20 +9,18 @@
[![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/)
## Table of Contents
- [Tasks](#tasks)
- [Medium](#medium)
- [YouTube](#youtube)
- [Bounties](#bounties)
- [MailChimp](#mailchimp)
- [Zoho](#zoho)
- [Campaigns API](#campaigns-api)
- [CRM API](#crm-api)
- [Development](#development)
- [Deployment](#deployment)
- [Authors](#authors)
- [License](#license)
- [Tasks](#tasks)
- [Medium](#medium)
- [YouTube](#youtube)
- [Bounties](#bounties)
- [MailChimp](#mailchimp)
- [Zoho](#zoho)
- [Campaigns API](#campaigns-api)
- [CRM API](#crm-api)
- [Development](#development)
- [Deployment](#deployment)
- [Authors](#authors)
- [License](#license)
---
@ -97,12 +95,13 @@ https://TASK_URL/TASK_NAME/
**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
{
"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) => {
try {
const dataGitcoin = await getGitcoin()
const dataBountiesNetwork = await getBountiesNetwork()
const data = Object.assign(dataGitcoin, dataBountiesNetwork)
const dataTotal = await getTotal()
const data = Object.assign(dataGitcoin, dataBountiesNetwork, dataTotal)
res.send(data)
} catch (error) {