fix balance notification
This commit is contained in:
parent
ec09aaeb7d
commit
6ee2566588
2 changed files with 5 additions and 3 deletions
|
|
@ -7,7 +7,7 @@ var db = require('../lib/postgresql_interface')
|
||||||
function getBalances () {
|
function getBalances () {
|
||||||
return [
|
return [
|
||||||
{fiatBalance: 23.2345, fiatCode: 'USD', cryptoCode: 'BTC'},
|
{fiatBalance: 23.2345, fiatCode: 'USD', cryptoCode: 'BTC'},
|
||||||
{fiatBalance: 22, fiatCode: 'USD', cryptoCode: 'ETH'}
|
{fiatBalance: 23, fiatCode: 'USD', cryptoCode: 'ETH'}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ var numeral = require('numeral')
|
||||||
var db = null
|
var db = null
|
||||||
var getBalances = null
|
var getBalances = null
|
||||||
|
|
||||||
var LOW_BALANCE_THRESHOLD = 1000
|
var LOW_BALANCE_THRESHOLD = null
|
||||||
var STALE_STATE = 2 * 60 * 1000
|
var STALE_STATE = 2 * 60 * 1000
|
||||||
var NETWORK_DOWN_TIME = 60 * 1000
|
var NETWORK_DOWN_TIME = 60 * 1000
|
||||||
|
|
||||||
|
|
@ -13,6 +13,8 @@ function init (_db, _getBalances, config) {
|
||||||
db = _db
|
db = _db
|
||||||
getBalances = _getBalances
|
getBalances = _getBalances
|
||||||
|
|
||||||
|
console.log('DEBUG2')
|
||||||
|
console.log(config)
|
||||||
if (config && config.lowBalanceThreshold) {
|
if (config && config.lowBalanceThreshold) {
|
||||||
LOW_BALANCE_THRESHOLD = config.lowBalanceThreshold
|
LOW_BALANCE_THRESHOLD = config.lowBalanceThreshold
|
||||||
}
|
}
|
||||||
|
|
@ -30,7 +32,7 @@ function sameState (a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkBalance (rec) {
|
function checkBalance (rec) {
|
||||||
return rec.fiatBalance < LOW_BALANCE_THRESHOLD
|
return LOW_BALANCE_THRESHOLD && rec.fiatBalance < LOW_BALANCE_THRESHOLD
|
||||||
? {code: 'lowBalance', cryptoCode: rec.cryptoCode, fiatBalance: rec.fiatBalance, fiatCode: rec.fiatCode}
|
? {code: 'lowBalance', cryptoCode: rec.cryptoCode, fiatBalance: rec.fiatBalance, fiatCode: rec.fiatCode}
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue