refactor: use recyclers instead of stackers

This commit is contained in:
Rafael Taranto 2023-10-09 14:41:33 +01:00
parent dc52cf4414
commit 21b88f182e
37 changed files with 2868 additions and 9599 deletions

View file

@ -40,18 +40,18 @@ exports.cassetteCounts = function cassetteCounts (deviceId) {
})
}
exports.stackerCounts = function stackerCounts (deviceId) {
const sql = 'SELECT stacker1f, stacker1r, stacker2f, stacker2r, stacker3f, stacker3r, number_of_stackers FROM devices ' +
exports.recyclerCounts = function recyclerCounts (deviceId) {
const sql = 'SELECT recycler1, recycler2, recycler3, recycler4, recycler5, recycler6, number_of_recyclers FROM devices ' +
'WHERE device_id=$1'
return db.one(sql, [deviceId])
.then(row => {
const counts = []
_.forEach(it => {
counts.push([row[`stacker${it + 1}f`], row[`stacker${it + 1}r`]])
}, _.times(_.identity(), row.number_of_stackers))
counts.push(row[`recycler${it + 1}`])
}, _.times(_.identity(), row.number_of_recyclers))
return { numberOfStackers: row.number_of_stackers, counts }
return { numberOfRecyclers: row.number_of_recyclers, counts }
})
}