fix: code review changes
This commit is contained in:
parent
e58acdb8be
commit
1e1bfe58a4
3 changed files with 10 additions and 10 deletions
|
|
@ -45,7 +45,7 @@ function insertNewBills (t, billRows, machineTx) {
|
|||
// bills before 8.6 don't have destination_unit
|
||||
const dbBills = _.map(_.defaults({ destination_unit: 'cashbox'}))(_dbBills)
|
||||
|
||||
const getBillsByDestination = destination => _.filter(it => it.destination_unit === destination)(dbBills)
|
||||
const billsByDestination = _.countBy(_.get(['distination_unit']) ,dbBills)
|
||||
|
||||
const columns = ['id', 'fiat', 'fiat_code', 'crypto_code', 'cash_in_fee', 'cash_in_txs_id', 'device_time', 'destination_unit']
|
||||
const sql = pgp.helpers.insert(dbBills, columns, 'bills')
|
||||
|
|
@ -55,12 +55,12 @@ function insertNewBills (t, billRows, machineTx) {
|
|||
|
||||
return t.none(sql2, [
|
||||
deviceID,
|
||||
getBillsByDestination('recycler1').length,
|
||||
getBillsByDestination('recycler2').length,
|
||||
getBillsByDestination('recycler3').length,
|
||||
getBillsByDestination('recycler4').length,
|
||||
getBillsByDestination('recycler5').length,
|
||||
getBillsByDestination('recycler6').length
|
||||
_.defaultTo(0, billsByDestination.recycler1),
|
||||
_.defaultTo(0, billsByDestination.recycler2),
|
||||
_.defaultTo(0, billsByDestination.recycler3),
|
||||
_.defaultTo(0, billsByDestination.recycler4),
|
||||
_.defaultTo(0, billsByDestination.recycler5),
|
||||
_.defaultTo(0, billsByDestination.recycler6)
|
||||
])
|
||||
.then(() => {
|
||||
return t.none(sql)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue