more refactoring
This commit is contained in:
parent
8acbc90dbd
commit
9a9c927801
6 changed files with 30 additions and 30 deletions
|
|
@ -44,7 +44,7 @@ exports.init = function init (conString) {
|
|||
exports.recordBill = function recordBill (deviceId, rec) {
|
||||
const fields = [
|
||||
'id',
|
||||
'device_fingerprint',
|
||||
'device_id',
|
||||
'currency_code',
|
||||
'crypto_code',
|
||||
'to_address',
|
||||
|
|
@ -246,7 +246,7 @@ exports.addDispense = function addDispense (deviceId, tx, cartridges) {
|
|||
|
||||
exports.cartridgeCounts = function cartridgeCounts (deviceId) {
|
||||
const sql = 'SELECT id, count1, count2 FROM dispenses ' +
|
||||
'WHERE device_fingerprint=$1 AND refill=$2 ' +
|
||||
'WHERE device_id=$1 AND refill=$2 ' +
|
||||
'ORDER BY id DESC LIMIT 1'
|
||||
return db.oneOrNone(sql, [deviceId, true])
|
||||
.then(row => {
|
||||
|
|
@ -257,9 +257,9 @@ exports.cartridgeCounts = function cartridgeCounts (deviceId) {
|
|||
|
||||
exports.machineEvent = function machineEvent (rec) {
|
||||
const TTL = 2 * 60 * 60 * 1000
|
||||
const fields = ['id', 'device_fingerprint', 'event_type', 'note', 'device_time']
|
||||
const fields = ['id', 'device_id', 'event_type', 'note', 'device_time']
|
||||
const sql = getInsertQuery('machine_events', fields)
|
||||
const values = [rec.id, rec.fingerprint, rec.eventType, rec.note, rec.deviceTime]
|
||||
const values = [rec.id, rec.deviceId, rec.eventType, rec.note, rec.deviceTime]
|
||||
const deleteSql = 'DELETE FROM machine_events WHERE (EXTRACT(EPOCH FROM (now() - created))) * 1000 > $1'
|
||||
const deleteValues = [TTL]
|
||||
|
||||
|
|
@ -268,7 +268,7 @@ exports.machineEvent = function machineEvent (rec) {
|
|||
}
|
||||
|
||||
exports.devices = function devices () {
|
||||
const sql = 'SELECT fingerprint, name FROM devices WHERE authorized=$1'
|
||||
const sql = 'SELECT device_id, name FROM devices WHERE authorized=$1'
|
||||
return db.any(sql, [true])
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue