commit
8bffde15a2
|
@ -616,6 +616,7 @@ ExpressApp.prototype.start = function(opts, cb) {
|
||||||
router.get('/v1/stats/', function(req, res) {
|
router.get('/v1/stats/', function(req, res) {
|
||||||
var opts = {};
|
var opts = {};
|
||||||
if (req.query.network) opts.network = req.query.network;
|
if (req.query.network) opts.network = req.query.network;
|
||||||
|
if (req.query.coin) opts.coin = req.query.coin;
|
||||||
if (req.query.from) opts.from = req.query.from;
|
if (req.query.from) opts.from = req.query.from;
|
||||||
if (req.query.to) opts.to = req.query.to;
|
if (req.query.to) opts.to = req.query.to;
|
||||||
|
|
||||||
|
|
11
lib/stats.js
11
lib/stats.js
|
@ -21,6 +21,7 @@ function Stats(opts) {
|
||||||
opts = opts || {};
|
opts = opts || {};
|
||||||
|
|
||||||
this.network = opts.network || 'livenet';
|
this.network = opts.network || 'livenet';
|
||||||
|
this.coin = opts.coin || 'btc';
|
||||||
this.from = moment(opts.from || INITIAL_DATE);
|
this.from = moment(opts.from || INITIAL_DATE);
|
||||||
this.to = moment(opts.to);
|
this.to = moment(opts.to);
|
||||||
this.fromTs = this.from.startOf('day').valueOf();
|
this.fromTs = this.from.startOf('day').valueOf();
|
||||||
|
@ -70,7 +71,7 @@ Stats.prototype._getNewWallets = function(cb) {
|
||||||
|
|
||||||
function getLastDate(cb) {
|
function getLastDate(cb) {
|
||||||
self.db.collection('stats_wallets')
|
self.db.collection('stats_wallets')
|
||||||
.find({})
|
.find({'_id.coin': self.coin})
|
||||||
.sort({
|
.sort({
|
||||||
'_id.day': -1
|
'_id.day': -1
|
||||||
})
|
})
|
||||||
|
@ -91,6 +92,7 @@ Stats.prototype._getNewWallets = function(cb) {
|
||||||
var key = {
|
var key = {
|
||||||
day: +day,
|
day: +day,
|
||||||
network: this.network,
|
network: this.network,
|
||||||
|
coin: this.coin
|
||||||
};
|
};
|
||||||
var value = {
|
var value = {
|
||||||
count: 1
|
count: 1
|
||||||
|
@ -127,6 +129,7 @@ Stats.prototype._getNewWallets = function(cb) {
|
||||||
self.db.collection('stats_wallets')
|
self.db.collection('stats_wallets')
|
||||||
.find({
|
.find({
|
||||||
'_id.network': self.network,
|
'_id.network': self.network,
|
||||||
|
'_id.coin': self.coin,
|
||||||
'_id.day': {
|
'_id.day': {
|
||||||
$gte: self.fromTs,
|
$gte: self.fromTs,
|
||||||
$lte: self.toTs,
|
$lte: self.toTs,
|
||||||
|
@ -142,6 +145,7 @@ Stats.prototype._getNewWallets = function(cb) {
|
||||||
var day = moment(record._id.day).format('YYYYMMDD');
|
var day = moment(record._id.day).format('YYYYMMDD');
|
||||||
return {
|
return {
|
||||||
day: day,
|
day: day,
|
||||||
|
coin: record._id.coin,
|
||||||
count: record.value.count,
|
count: record.value.count,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -181,7 +185,7 @@ Stats.prototype._getTxProposals = function(cb) {
|
||||||
|
|
||||||
function getLastDate(cb) {
|
function getLastDate(cb) {
|
||||||
self.db.collection('stats_txps')
|
self.db.collection('stats_txps')
|
||||||
.find({})
|
.find({'_id.coin': self.coin })
|
||||||
.sort({
|
.sort({
|
||||||
'_id.day': -1
|
'_id.day': -1
|
||||||
})
|
})
|
||||||
|
@ -202,6 +206,7 @@ Stats.prototype._getTxProposals = function(cb) {
|
||||||
var key = {
|
var key = {
|
||||||
day: +day,
|
day: +day,
|
||||||
network: this.network,
|
network: this.network,
|
||||||
|
coin: this.coin
|
||||||
};
|
};
|
||||||
var value = {
|
var value = {
|
||||||
count: 1,
|
count: 1,
|
||||||
|
@ -243,6 +248,7 @@ Stats.prototype._getTxProposals = function(cb) {
|
||||||
self.db.collection('stats_txps')
|
self.db.collection('stats_txps')
|
||||||
.find({
|
.find({
|
||||||
'_id.network': self.network,
|
'_id.network': self.network,
|
||||||
|
'_id.coin': self.coin,
|
||||||
'_id.day': {
|
'_id.day': {
|
||||||
$gte: self.fromTs,
|
$gte: self.fromTs,
|
||||||
$lte: self.toTs,
|
$lte: self.toTs,
|
||||||
|
@ -262,6 +268,7 @@ Stats.prototype._getTxProposals = function(cb) {
|
||||||
var day = moment(record._id.day).format('YYYYMMDD');
|
var day = moment(record._id.day).format('YYYYMMDD');
|
||||||
stats.nbByDay.push({
|
stats.nbByDay.push({
|
||||||
day: day,
|
day: day,
|
||||||
|
coin: record._id.coin,
|
||||||
count: record.value.count,
|
count: record.value.count,
|
||||||
});
|
});
|
||||||
stats.amountByDay.push({
|
stats.amountByDay.push({
|
||||||
|
|
Loading…
Reference in New Issue