Fix getlasttxs api
-Completely removed the /ext/getlasttxsajax api and replaced with /ext/getlasttxs -Fixed record count for movement page
This commit is contained in:
@@ -210,12 +210,6 @@ app.use('/ext/getlasttxs/:min', function(req, res) {
|
||||
});
|
||||
});
|
||||
|
||||
app.use('/ext/getlasttxsajax/:min', function(req, res){
|
||||
db.get_last_txs(req, function(data, draw, count) {
|
||||
res.json({"data":data, "draw": draw, "recordsTotal": count, "recordsFiltered": count});
|
||||
});
|
||||
});
|
||||
|
||||
app.use('/ext/getaddresstxsajax/:address', function(req,res){
|
||||
req.query.length = parseInt(req.query.length);
|
||||
if(isNaN(req.query.length) || req.query.length > settings.txcount){
|
||||
|
||||
+16
-1
@@ -422,7 +422,21 @@ module.exports = {
|
||||
},
|
||||
|
||||
get_last_txs_ajax: function(start, length, min, cb) {
|
||||
// Lookup the coin stats to get the txes value which is used to determine the total # of records
|
||||
// check if min is greater than zero
|
||||
if (min > 0) {
|
||||
// min is greater than zero which means we must pull record count from the txes collection
|
||||
Tx.find({'total': {$gte: min}}).countDocuments(function(err, count) {
|
||||
// Get last transactions where there is at least 1 vout
|
||||
Tx.find({'total': {$gte: min}, 'vout': { $gte: { $size: 1 }}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
} else {
|
||||
return cb(txs, count);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
// min is zero (shouldn't ever be negative) which means we must pull record count from the coinstats collection (pulling from txes could potentially take a long time because it would include coinbase txes)
|
||||
Stats.findOne({coin:settings.coin}, function(err, stats) {
|
||||
// Get last transactions where there is at least 1 vout
|
||||
Tx.find({'total': {$gte: min}, 'vout': { $gte: { $size: 1 }}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs) {
|
||||
@@ -433,6 +447,7 @@ module.exports = {
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
get_address_txs_ajax: function(hash, start, length, cb) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ block content
|
||||
serverSide: true,
|
||||
iDisplayLength: displayLengthMax,
|
||||
lengthMenu: lengthMenuOpts,
|
||||
ajax: '/ext/getlasttxsajax/0',
|
||||
ajax: '/ext/getlasttxs/0',
|
||||
language: {
|
||||
paginate: {
|
||||
previous: '<',
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ block content
|
||||
serverSide: true,
|
||||
iDisplayLength: displayLengthMax,
|
||||
lengthMenu: lengthMenuOpts,
|
||||
ajax: '/ext/getlasttxsajax/#{min_amount}',
|
||||
ajax: '/ext/getlasttxs/#{min_amount}',
|
||||
language: {
|
||||
paginate: {
|
||||
previous: '<',
|
||||
|
||||
Reference in New Issue
Block a user