feat: add failedqrscans route
This commit is contained in:
parent
60b016efb4
commit
79fc7f3c44
3 changed files with 26 additions and 4 deletions
|
|
@ -492,6 +492,12 @@ function updateDiagnostics (deviceId, images) {
|
||||||
.catch(err => logger.error('while running machine diagnostics: ', err))
|
.catch(err => logger.error('while running machine diagnostics: ', err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const updateFailedQRScans = (deviceId, frames) => {
|
||||||
|
const directory = `${OPERATOR_DATA_DIR}/failedQRScans/${deviceId}/`
|
||||||
|
const filenames = _.map(no => `${no}.jpg`, _.range(0, _.size(frames)))
|
||||||
|
return updatePhotos(directory, _.zip(filenames, frames))
|
||||||
|
}
|
||||||
|
|
||||||
function createPhoto (name, data, dir) {
|
function createPhoto (name, data, dir) {
|
||||||
if (!data) {
|
if (!data) {
|
||||||
logger.error(`Diagnostics error: No data to save for ${name} photo`)
|
logger.error(`Diagnostics error: No data to save for ${name} photo`)
|
||||||
|
|
@ -506,9 +512,8 @@ function createPhoto (name, data, dir) {
|
||||||
function updatePhotos (dir, photoPairs) {
|
function updatePhotos (dir, photoPairs) {
|
||||||
const dirname = path.join(dir)
|
const dirname = path.join(dir)
|
||||||
_.attempt(() => makeDir.sync(dirname))
|
_.attempt(() => makeDir.sync(dirname))
|
||||||
return Promise.all(_.map(
|
return Promise.all(photoPairs.map(
|
||||||
([filename, data]) => createPhoto(filename, data, dirname),
|
([filename, data]) => createPhoto(filename, data, dirname)
|
||||||
photoPairs
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -527,5 +532,6 @@ module.exports = {
|
||||||
getMachineIds,
|
getMachineIds,
|
||||||
emptyMachineUnits,
|
emptyMachineUnits,
|
||||||
refillMachineUnits,
|
refillMachineUnits,
|
||||||
updateDiagnostics
|
updateDiagnostics,
|
||||||
|
updateFailedQRScans
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,6 +32,7 @@ const verifyUserRoutes = require('./routes/verifyUserRoutes')
|
||||||
const verifyTxRoutes = require('./routes/verifyTxRoutes')
|
const verifyTxRoutes = require('./routes/verifyTxRoutes')
|
||||||
const verifyPromoCodeRoutes = require('./routes/verifyPromoCodeRoutes')
|
const verifyPromoCodeRoutes = require('./routes/verifyPromoCodeRoutes')
|
||||||
const probeRoutes = require('./routes/probeLnRoutes')
|
const probeRoutes = require('./routes/probeLnRoutes')
|
||||||
|
const failedQRScansRoutes = require('./routes/failedQRScans')
|
||||||
|
|
||||||
const graphQLServer = require('./graphql/server')
|
const graphQLServer = require('./graphql/server')
|
||||||
|
|
||||||
|
|
@ -75,6 +76,7 @@ app.use('/cashbox', cashboxRoutes)
|
||||||
|
|
||||||
app.use('/network', performanceRoutes)
|
app.use('/network', performanceRoutes)
|
||||||
app.use('/diagnostics', diagnosticsRoutes)
|
app.use('/diagnostics', diagnosticsRoutes)
|
||||||
|
app.use('/failedqrscans', failedQRScansRoutes)
|
||||||
|
|
||||||
app.use('/verify_user', verifyUserRoutes)
|
app.use('/verify_user', verifyUserRoutes)
|
||||||
app.use('/verify_transaction', verifyTxRoutes)
|
app.use('/verify_transaction', verifyTxRoutes)
|
||||||
|
|
|
||||||
14
lib/routes/failedQRScans.js
Normal file
14
lib/routes/failedQRScans.js
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
const express = require('express')
|
||||||
|
const router = express.Router()
|
||||||
|
|
||||||
|
const { updateFailedQRScans } = require('../machine-loader')
|
||||||
|
|
||||||
|
function failedQRScans (req, res, next) {
|
||||||
|
return updateFailedQRScans(req.deviceId, req.body)
|
||||||
|
.then(() => res.status(200).send({ status: 'OK' }))
|
||||||
|
.catch(next)
|
||||||
|
}
|
||||||
|
|
||||||
|
router.post('/', failedQRScans)
|
||||||
|
|
||||||
|
module.exports = router
|
||||||
Loading…
Add table
Add a link
Reference in a new issue