Add new "last updated date" settings

-Added new configurable settings to allow displaying a "last updated date" timestamp for: index, reward, masternode, movement, network, richlist and market pages
-Affected pages are now configured to be completely hidden and disabled when their display settings are set to false
This commit is contained in:
joeuhren
2020-12-31 15:19:48 -07:00
parent 9488e7e588
commit 2fd39d76ce
14 changed files with 357 additions and 89 deletions
+47 -8
View File
@@ -759,10 +759,12 @@ module.exports = {
return cb(distribution);
});
},
// updates heavy stats for coin
// height: current block height, count: amount of votes to store
update_heavy: function(coin, height, count, cb) {
var newVotes = [];
lib.get_maxmoney( function (maxmoney) {
lib.get_maxvote( function (maxvote) {
lib.get_vote( function (vote) {
@@ -773,14 +775,13 @@ module.exports = {
lib.get_nextin( function (nextin) {
lib.syncLoop(count, function (loop) {
var i = loop.iteration();
lib.get_blockhash(height-i, function (hash) {
lib.get_blockhash(height - i, function (hash) {
lib.get_block(hash, function (block) {
newVotes.push({count:height-i,reward:block.reward,vote:(block && block.vote ? block.vote : 0)});
newVotes.push({ count: height - i, reward: block.reward, vote: (block && block.vote ? block.vote : 0) });
loop.next();
});
});
}, function(){
console.log(newVotes);
}, function() {
Heavy.updateOne({coin: coin}, {
lvote: (vote ? vote : 0),
reward: (reward ? reward : 0),
@@ -790,10 +791,13 @@ module.exports = {
phase: (phase ? phase : 'N/A'),
maxvote: (maxvote ? maxvote : 0),
nextin: (nextin ? nextin : 'N/A'),
votes: newVotes,
votes: newVotes
}, function() {
//console.log('address updated: %s', hash);
return cb();
// update reward_last_updated value
module.exports.update_last_updated_stats(settings.coin, { reward_last_updated: Math.floor(new Date() / 1000) }, function (new_cb) {
console.log('heavy update complete');
return cb();
});
});
});
});
@@ -1195,13 +1199,48 @@ module.exports = {
// updates last_updated stats; called by sync.js
update_last_updated_stats: function (coin, param, cb) {
if (param.masternodes_last_updated) {
if (param.blockchain_last_updated) {
// update blockchain last updated date
Stats.updateOne({ coin: coin }, {
blockchain_last_updated: param.blockchain_last_updated
}, function () {
return cb(true);
});
} else if (param.reward_last_updated) {
// update reward last updated date
Stats.updateOne({ coin: coin }, {
reward_last_updated: param.reward_last_updated
}, function () {
return cb(true);
});
} else if (param.masternodes_last_updated) {
// update masternode last updated date
Stats.updateOne({ coin: coin }, {
masternodes_last_updated: param.masternodes_last_updated
}, function () {
return cb(true);
});
} else if (param.network_last_updated) {
// update network last updated date
Stats.updateOne({ coin: coin }, {
network_last_updated: param.network_last_updated
}, function () {
return cb(true);
});
} else if (param.richlist_last_updated) {
// update richlist last updated date
Stats.updateOne({ coin: coin }, {
richlist_last_updated: param.richlist_last_updated
}, function () {
return cb(true);
});
} else if (param.markets_last_updated) {
// update markets last updated date
Stats.updateOne({ coin: coin }, {
markets_last_updated: param.markets_last_updated
}, function () {
return cb(true);
});
} else {
// invalid option
return cb(false);