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){
|
app.use('/ext/getaddresstxsajax/:address', function(req,res){
|
||||||
req.query.length = parseInt(req.query.length);
|
req.query.length = parseInt(req.query.length);
|
||||||
if(isNaN(req.query.length) || req.query.length > settings.txcount){
|
if(isNaN(req.query.length) || req.query.length > settings.txcount){
|
||||||
|
|||||||
+25
-10
@@ -422,17 +422,32 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
get_last_txs_ajax: function(start, length, min, cb) {
|
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
|
||||||
Stats.findOne({coin:settings.coin}, function(err, stats) {
|
if (min > 0) {
|
||||||
// Get last transactions where there is at least 1 vout
|
// min is greater than zero which means we must pull record count from the txes collection
|
||||||
Tx.find({'total': {$gte: min}, 'vout': { $gte: { $size: 1 }}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs) {
|
Tx.find({'total': {$gte: min}}).countDocuments(function(err, count) {
|
||||||
if (err) {
|
// Get last transactions where there is at least 1 vout
|
||||||
return cb(err);
|
Tx.find({'total': {$gte: min}, 'vout': { $gte: { $size: 1 }}}).sort({blockindex: -1}).skip(Number(start)).limit(Number(length)).exec(function(err, txs) {
|
||||||
} else {
|
if (err) {
|
||||||
return cb(txs, stats.txes);
|
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) {
|
||||||
|
if (err) {
|
||||||
|
return cb(err);
|
||||||
|
} else {
|
||||||
|
return cb(txs, stats.txes);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
get_address_txs_ajax: function(hash, start, length, cb) {
|
get_address_txs_ajax: function(hash, start, length, cb) {
|
||||||
|
|||||||
+1
-1
@@ -28,7 +28,7 @@ block content
|
|||||||
serverSide: true,
|
serverSide: true,
|
||||||
iDisplayLength: displayLengthMax,
|
iDisplayLength: displayLengthMax,
|
||||||
lengthMenu: lengthMenuOpts,
|
lengthMenu: lengthMenuOpts,
|
||||||
ajax: '/ext/getlasttxsajax/0',
|
ajax: '/ext/getlasttxs/0',
|
||||||
language: {
|
language: {
|
||||||
paginate: {
|
paginate: {
|
||||||
previous: '<',
|
previous: '<',
|
||||||
|
|||||||
+1
-1
@@ -29,7 +29,7 @@ block content
|
|||||||
serverSide: true,
|
serverSide: true,
|
||||||
iDisplayLength: displayLengthMax,
|
iDisplayLength: displayLengthMax,
|
||||||
lengthMenu: lengthMenuOpts,
|
lengthMenu: lengthMenuOpts,
|
||||||
ajax: '/ext/getlasttxsajax/#{min_amount}',
|
ajax: '/ext/getlasttxs/#{min_amount}',
|
||||||
language: {
|
language: {
|
||||||
paginate: {
|
paginate: {
|
||||||
previous: '<',
|
previous: '<',
|
||||||
|
|||||||
Reference in New Issue
Block a user