Fix: fix query
This commit is contained in:
parent
ed4e654036
commit
0b02c7feae
1 changed files with 5 additions and 5 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
const _ = require('lodash/fp')
|
const _ = require('lodash/fp')
|
||||||
|
const pgp = require('pg-promise')()
|
||||||
|
|
||||||
const db = require('../db')
|
const db = require('../db')
|
||||||
const machineLoader = require('../machine-loader')
|
const machineLoader = require('../machine-loader')
|
||||||
|
|
@ -81,7 +82,7 @@ function getCustomerTransactionsBatch (ids) {
|
||||||
((not txs.send_confirmed) and (txs.created <= now() - interval $2)) as expired
|
((not txs.send_confirmed) and (txs.created <= now() - interval $2)) as expired
|
||||||
from cash_in_txs as txs
|
from cash_in_txs as txs
|
||||||
left outer join customers c on txs.customer_id = c.id
|
left outer join customers c on txs.customer_id = c.id
|
||||||
where c.id::text LIKE ANY($1)
|
where c.id IN ($1^)
|
||||||
order by created desc limit $3`
|
order by created desc limit $3`
|
||||||
|
|
||||||
const cashOutSql = `select 'cashOut' as tx_class,
|
const cashOutSql = `select 'cashOut' as tx_class,
|
||||||
|
|
@ -99,12 +100,11 @@ function getCustomerTransactionsBatch (ids) {
|
||||||
inner join cash_out_actions actions on txs.id = actions.tx_id
|
inner join cash_out_actions actions on txs.id = actions.tx_id
|
||||||
and actions.action = 'provisionAddress'
|
and actions.action = 'provisionAddress'
|
||||||
left outer join customers c on txs.customer_id = c.id
|
left outer join customers c on txs.customer_id = c.id
|
||||||
where c.id::text LIKE ANY ($1)
|
where c.id IN ($1^)
|
||||||
order by created desc limit $2`
|
order by created desc limit $2`
|
||||||
|
|
||||||
return Promise.all([
|
return Promise.all([
|
||||||
db.any(cashInSql, [ids, cashInTx.PENDING_INTERVAL, NUM_RESULTS]),
|
db.any(cashInSql, [_.map(pgp.as.text, ids).join(','), cashInTx.PENDING_INTERVAL, NUM_RESULTS]),
|
||||||
db.any(cashOutSql, [ids, NUM_RESULTS, REDEEMABLE_AGE])
|
db.any(cashOutSql, [_.map(pgp.as.text, ids).join(','), NUM_RESULTS, REDEEMABLE_AGE])
|
||||||
])
|
])
|
||||||
.then(packager).then(transactions => {
|
.then(packager).then(transactions => {
|
||||||
const transactionMap = _.groupBy('customerId', transactions)
|
const transactionMap = _.groupBy('customerId', transactions)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue