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))
|
||||
}
|
||||
|
||||
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) {
|
||||
if (!data) {
|
||||
logger.error(`Diagnostics error: No data to save for ${name} photo`)
|
||||
|
|
@ -506,9 +512,8 @@ function createPhoto (name, data, dir) {
|
|||
function updatePhotos (dir, photoPairs) {
|
||||
const dirname = path.join(dir)
|
||||
_.attempt(() => makeDir.sync(dirname))
|
||||
return Promise.all(_.map(
|
||||
([filename, data]) => createPhoto(filename, data, dirname),
|
||||
photoPairs
|
||||
return Promise.all(photoPairs.map(
|
||||
([filename, data]) => createPhoto(filename, data, dirname)
|
||||
))
|
||||
}
|
||||
|
||||
|
|
@ -527,5 +532,6 @@ module.exports = {
|
|||
getMachineIds,
|
||||
emptyMachineUnits,
|
||||
refillMachineUnits,
|
||||
updateDiagnostics
|
||||
updateDiagnostics,
|
||||
updateFailedQRScans
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue