fix: added timestamp parameters for a date range on the gql queries for
machineLogs, serverLogs and transactions feat: added optional limit and offset variables for the logs queries, for filtering and pagination feat: adapted the LogsDownloaderPopper to download the logs by whats set on the filters fix: improved code readability fix: avoid errors when the range option is selected and no range is actually selected
This commit is contained in:
parent
37ea3a04c3
commit
f641e605a4
7 changed files with 109 additions and 68 deletions
|
|
@ -23,9 +23,8 @@ function addNames (txs) {
|
|||
|
||||
const camelize = _.mapKeys(_.camelCase)
|
||||
|
||||
function batch () {
|
||||
const packager = _.flow(_.flatten, _.orderBy(_.property('created'), ['desc']),
|
||||
_.take(NUM_RESULTS), _.map(camelize), addNames)
|
||||
function batch (from = new Date(0).toISOString(), until = new Date().toISOString(), limit = null, offset = 0) {
|
||||
const packager = _.flow(_.flatten, _.orderBy(_.property('created'), ['desc']), _.map(camelize), addNames)
|
||||
|
||||
const cashInSql = `select 'cashIn' as tx_class, txs.*,
|
||||
c.phone as customer_phone,
|
||||
|
|
@ -38,7 +37,8 @@ function batch () {
|
|||
((not txs.send_confirmed) and (txs.created <= now() - interval $1)) as expired
|
||||
from cash_in_txs as txs
|
||||
left outer join customers c on txs.customer_id = c.id
|
||||
order by created desc limit $2`
|
||||
where txs.created >= $2 and txs.created <= $3
|
||||
order by created desc limit $4 offset $5`
|
||||
|
||||
const cashOutSql = `select 'cashOut' as tx_class,
|
||||
txs.*,
|
||||
|
|
@ -50,14 +50,18 @@ function batch () {
|
|||
c.name as customer_name,
|
||||
c.front_camera_path as customer_front_camera_path,
|
||||
c.id_card_photo_path as customer_id_card_photo_path,
|
||||
(extract(epoch from (now() - greatest(txs.created, txs.confirmed_at))) * 1000) >= $2 as expired
|
||||
(extract(epoch from (now() - greatest(txs.created, txs.confirmed_at))) * 1000) >= $1 as expired
|
||||
from cash_out_txs txs
|
||||
inner join cash_out_actions actions on txs.id = actions.tx_id
|
||||
and actions.action = 'provisionAddress'
|
||||
left outer join customers c on txs.customer_id = c.id
|
||||
order by created desc limit $1`
|
||||
where txs.created >= $2 and txs.created <= $3
|
||||
order by created desc limit $4 offset $5`
|
||||
|
||||
return Promise.all([db.any(cashInSql, [cashInTx.PENDING_INTERVAL, NUM_RESULTS]), db.any(cashOutSql, [NUM_RESULTS, REDEEMABLE_AGE])])
|
||||
return Promise.all([
|
||||
db.any(cashInSql, [cashInTx.PENDING_INTERVAL, from, until, limit, offset]),
|
||||
db.any(cashOutSql, [REDEEMABLE_AGE, from, until, limit, offset])
|
||||
])
|
||||
.then(packager)
|
||||
}
|
||||
|
||||
|
|
@ -65,8 +69,7 @@ function getCustomerTransactions (customerId) {
|
|||
const packager = _.flow(it => {
|
||||
console.log()
|
||||
return it
|
||||
}, _.flatten, _.orderBy(_.property('created'), ['desc']),
|
||||
_.take(NUM_RESULTS), _.map(camelize), addNames)
|
||||
}, _.flatten, _.orderBy(_.property('created'), ['desc']), _.map(camelize), addNames)
|
||||
|
||||
const cashInSql = `select 'cashIn' as tx_class, txs.*,
|
||||
c.phone as customer_phone,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue