fix: code review changes

This commit is contained in:
Rafael Taranto 2023-10-16 16:58:47 +01:00
parent e58acdb8be
commit 1e1bfe58a4
3 changed files with 10 additions and 10 deletions

View file

@ -45,7 +45,7 @@ function insertNewBills (t, billRows, machineTx) {
// bills before 8.6 don't have destination_unit // bills before 8.6 don't have destination_unit
const dbBills = _.map(_.defaults({ destination_unit: 'cashbox'}))(_dbBills) 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 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') const sql = pgp.helpers.insert(dbBills, columns, 'bills')
@ -55,12 +55,12 @@ function insertNewBills (t, billRows, machineTx) {
return t.none(sql2, [ return t.none(sql2, [
deviceID, deviceID,
getBillsByDestination('recycler1').length, _.defaultTo(0, billsByDestination.recycler1),
getBillsByDestination('recycler2').length, _.defaultTo(0, billsByDestination.recycler2),
getBillsByDestination('recycler3').length, _.defaultTo(0, billsByDestination.recycler3),
getBillsByDestination('recycler4').length, _.defaultTo(0, billsByDestination.recycler4),
getBillsByDestination('recycler5').length, _.defaultTo(0, billsByDestination.recycler5),
getBillsByDestination('recycler6').length _.defaultTo(0, billsByDestination.recycler6)
]) ])
.then(() => { .then(() => {
return t.none(sql) return t.none(sql)

View file

@ -127,7 +127,7 @@ const getCashUnitFieldName = (step, numberOfCassettes, numberOfRecyclers) => {
category: 'cassette' category: 'cassette'
} }
const recyclerStepsStart = CASHBOX_STEP + numberOfCassettes + 1 const recyclerStepsStart = CASHBOX_STEP + numberOfCassettes + 1
if (step < recyclerStepsStart + numberOfRecyclers * 2) if (step < recyclerStepsStart + numberOfRecyclers)
return { return {
name: `recycler${Math.ceil(step - recyclerStepsStart + 1)}`, name: `recycler${Math.ceil(step - recyclerStepsStart + 1)}`,
category: 'recycler' category: 'recycler'

View file

@ -185,7 +185,7 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => {
percent={ percent={
values[ values[
`fillingPercentageRecycler${(it + 1) * 2 - 1}` `fillingPercentageRecycler${(it + 1) * 2 - 1}`
] ?? data[`recycler${(it + 1) * 2 - 1}f`] ] ?? data[`recycler${(it + 1) * 2 - 1}`]
} }
applyColorVariant applyColorVariant
applyFiatBalanceAlertsStyling applyFiatBalanceAlertsStyling
@ -237,7 +237,7 @@ const FiatBalance = ({ section, min = 0, max = 100, fieldWidth = 80 }) => {
</div> </div>
</> </>
], ],
R.times(R.identity, maxNumberOfRecyclers) R.times(R.identity, maxNumberOfRecyclers / 2)
)} )}
</div> </div>
</Form> </Form>