mirror of
https://github.com/jwinterm/nodejs-pool.git
synced 2026-10-17 05:21:27 +02:00
Stats are now locked to only being available during a global tz. This should help deal with miners that have stats that run excessively far in comparison to the main system when they go offline for a day or two.
This commit is contained in:
+16
@@ -375,9 +375,11 @@ app.get('/miner/:address/stats', function (req, res) {
|
||||
let address_pt = address_parts[0];
|
||||
let payment_id = address_parts[1];
|
||||
let paidQuery = "SELECT SUM(amount) as amt FROM payments WHERE payment_address = ? AND payment_id = ?";
|
||||
let txnCount = "SELECT count(id) as amt FROM payments WHERE payment_address = ? AND payment_id = ?";
|
||||
let unpaidQuery = "SELECT SUM(amount) as amt FROM balance WHERE payment_address = ? AND payment_id = ?";
|
||||
if (typeof(payment_id) === 'undefined') {
|
||||
paidQuery = "SELECT SUM(amount) as amt FROM payments WHERE payment_address = ? AND payment_id IS ?";
|
||||
txnCount = "SELECT count(id) as amt FROM payments WHERE payment_address = ? AND payment_id IS ?";
|
||||
unpaidQuery = "SELECT SUM(amount) as amt FROM balance WHERE payment_address = ? AND payment_id IS ?";
|
||||
}
|
||||
async.waterfall([
|
||||
@@ -422,6 +424,20 @@ app.get('/miner/:address/stats', function (req, res) {
|
||||
}
|
||||
return callback(true, returnData);
|
||||
});
|
||||
},
|
||||
function (returnData, callback) {
|
||||
debug(threadName + "Checking MySQL total amount unpaid for /miner/address/stats");
|
||||
global.mysql.query(txnCount, [address_pt, payment_id]).then(function (rows) {
|
||||
if (typeof(rows[0]) === 'undefined') {
|
||||
returnData.txnCount = 0;
|
||||
} else {
|
||||
returnData.txnCount = rows[0].amt;
|
||||
if (returnData.txnCount === null) {
|
||||
returnData.txnCount = 0;
|
||||
}
|
||||
}
|
||||
return callback(true, returnData);
|
||||
});
|
||||
}
|
||||
], function (err, result) {
|
||||
debug(threadName + "Result information for " + address + ": " + JSON.stringify(result));
|
||||
|
||||
Reference in New Issue
Block a user