WIP: getAmount functionality

This commit is contained in:
Jordi Montes 2018-01-22 16:49:41 +01:00
parent 9c6038bfb4
commit 9b84e2bd7f

View File

@ -21,15 +21,6 @@ const logger = winston.createLogger({
] ]
}); });
const bountyLabels = {
'bounty-xs': 1,
'bounty-s': 10,
'bounty-m': 100,
'bounty-l': 1000,
'bounty-xl': 10000,
'bounty-xx': 100000
};
const needsFunding = function(req) { const needsFunding = function(req) {
if (req.body.action !== 'created' || !req.body.hasOwnProperty('comment')) if (req.body.action !== 'created' || !req.body.hasOwnProperty('comment'))
return false return false
@ -45,15 +36,16 @@ const getAddress = function(req) {
} }
const getLabel = function(req) { const getLabel = function(req) {
let labelNames = req.body.issue.labels.map(lableObj => lableObj.name); return github.getLabels(req)
.then(labels => {
labels = labelNames.filter(name => bountyLabels.hasOwnProperty(name)); if (labels.length === 1) {
resolve(labels[0]);
if (labels.length == 1) } else {
return labels[0]; // TODO: Handle error
}
//log error }).catch(err => {
return 0; // TODO: Handle error
});
} }
const getAmount = function(req) { const getAmount = function(req) {
@ -69,15 +61,6 @@ const getAmount = function(req) {
} }
const getGasPrice = function(req) {
let gasPricePromise = prices.getGasPrice();
gasPricePromise
.then((gasPrice) => {return gasPrice})
.catch((err) => {console.log("TODO-ERROR: Failed gas price request throw log error")});
// Check how to handle errors when promises does not arrive
}
const log = function(msg) { const log = function(msg) {
logger.info(msg); logger.info(msg);
} }
@ -87,6 +70,6 @@ module.exports = {
needsFunding: needsFunding, needsFunding: needsFunding,
getAddress: getAddress, getAddress: getAddress,
getAmount: getAmount, getAmount: getAmount,
getGasPrice: getGasPrice, getGasPrice: prices.getGasPrice,
log: log log: log
} }