WIP
This commit is contained in:
parent
f91992e20d
commit
11b5958c60
4 changed files with 77 additions and 19 deletions
|
|
@ -500,6 +500,36 @@ exports.addIncomingPhone = function addIncomingPhone (session, tx, cb) {
|
|||
})
|
||||
}
|
||||
|
||||
exports.fetchPhoneTxs = function fetchPhoneTxs (phone, dispenseTimeout, cb) {
|
||||
var sql = 'SELECT * FROM transactions ' +
|
||||
'WHERE phone=$1 AND dispensed=$2 ' +
|
||||
'AND (EXTRACT(EPOCH FROM (now() - created))) * 1000 < $1'
|
||||
|
||||
connect(function (cerr, client, done) {
|
||||
if (cerr) return cb(cerr)
|
||||
query(client, sql, [phone, false, dispenseTimeout], function (err, results) {
|
||||
done()
|
||||
if (err) return cb(err)
|
||||
cb(null, results.rows)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
exports.fetchTx = function fetchTx (session, cb) {
|
||||
var sql = 'SELECT * FROM transactions ' +
|
||||
'WHERE device_fingerprint=$1 AND session_id=$2 ' +
|
||||
'ORDER BY created'
|
||||
|
||||
connect(function (cerr, client, done) {
|
||||
if (cerr) return cb(cerr)
|
||||
query(client, sql, [session.fingerprint, session.id], function (err, results) {
|
||||
done()
|
||||
if (err) return cb(err)
|
||||
cb(null, results.rows)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function updateDispense (client, session, dispensed, cb) {
|
||||
var sql = 'UPDATE transactions SET dispense=$1 ' +
|
||||
'WHERE stage=$2 AND authority=$3 AND device_fingerprint=$4 AND session_id=$5'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue