feat: use the stacker amount to properly render the cash cassettes table feat: add stacker notifications to the plugins backend
36 lines
No EOL
1,004 B
JavaScript
36 lines
No EOL
1,004 B
JavaScript
#!/usr/bin/env node
|
|
|
|
require('../lib/environment-helper')
|
|
|
|
const _ = require('lodash')
|
|
const db = require('../lib/db')
|
|
|
|
if (process.argv.length !== 4) {
|
|
console.log('Usage: lamassu-update-stackers <device_id> <number_of_stackers>')
|
|
process.exit(1)
|
|
}
|
|
|
|
if (!_.isFinite(parseInt(process.argv[3]))) {
|
|
console.log('Error: <number_of_stackers> is not a valid number (%s)', err)
|
|
process.exit(3)
|
|
}
|
|
|
|
if (parseInt(process.argv[3]) > 3 || parseInt(process.argv[3]) < 1) {
|
|
console.log('Error: <number_of_stackers> is out of range. Should be a number between 1 and 3')
|
|
process.exit(3)
|
|
}
|
|
|
|
const deviceId = process.argv[2]
|
|
const numberOfStackers = parseInt(process.argv[3])
|
|
|
|
const query = `UPDATE devices SET number_of_stackers = $1 WHERE device_id = $2`
|
|
|
|
db.none(query, [numberOfStackers, deviceId])
|
|
.then(() => {
|
|
console.log('Success! Device %s updated to %s stackers', deviceId, numberOfStackers)
|
|
process.exit(0)
|
|
})
|
|
.catch(err => {
|
|
console.log('Error: %s', err)
|
|
process.exit(3)
|
|
}) |