From 1e1bfe58a4ebbfe5eb437b5713cb5c1d3ef2802f Mon Sep 17 00:00:00 2001 From: Rafael Taranto Date: Mon, 16 Oct 2023 16:58:47 +0100 Subject: [PATCH] fix: code review changes --- lib/cash-in/cash-in-atomic.js | 14 +++++++------- .../src/pages/Maintenance/Wizard/WizardStep.js | 2 +- .../Notifications/sections/FiatBalanceAlerts.js | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/cash-in/cash-in-atomic.js b/lib/cash-in/cash-in-atomic.js index 34620a95..8ef35976 100644 --- a/lib/cash-in/cash-in-atomic.js +++ b/lib/cash-in/cash-in-atomic.js @@ -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) diff --git a/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js b/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js index 418327ce..44498e2b 100644 --- a/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js +++ b/new-lamassu-admin/src/pages/Maintenance/Wizard/WizardStep.js @@ -127,7 +127,7 @@ const getCashUnitFieldName = (step, numberOfCassettes, numberOfRecyclers) => { category: 'cassette' } const recyclerStepsStart = CASHBOX_STEP + numberOfCassettes + 1 - if (step < recyclerStepsStart + numberOfRecyclers * 2) + if (step < recyclerStepsStart + numberOfRecyclers) return { name: `recycler${Math.ceil(step - recyclerStepsStart + 1)}`, category: 'recycler' diff --git a/new-lamassu-admin/src/pages/Notifications/sections/FiatBalanceAlerts.js b/new-lamassu-admin/src/pages/Notifications/sections/FiatBalanceAlerts.js index 28d93553..a4110989 100644 --- a/new-lamassu-admin/src/pages/Notifications/sections/FiatBalanceAlerts.js +++ b/new-lamassu-admin/src/pages/Notifications/sections/FiatBalanceAlerts.js @@ -185,7 +185,7 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => { percent={ values[ `fillingPercentageRecycler${(it + 1) * 2 - 1}` - ] ?? data[`recycler${(it + 1) * 2 - 1}f`] + ] ?? data[`recycler${(it + 1) * 2 - 1}`] } applyColorVariant applyFiatBalanceAlertsStyling @@ -237,7 +237,7 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => { ], - R.times(R.identity, maxNumberOfRecyclers) + R.times(R.identity, maxNumberOfRecyclers / 2) )}