Add processing for upload dlock
This commit is contained in:
46
services/integration/processingStatus.js
Normal file
46
services/integration/processingStatus.js
Normal file
@@ -0,0 +1,46 @@
|
||||
'use strict';
|
||||
|
||||
const db = require('../../models/index');
|
||||
|
||||
const setProcessingValue = (value) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const values = {processing: value};
|
||||
db.processing.update(values, {where:{}})
|
||||
.then(() => {
|
||||
resolve(true);
|
||||
})
|
||||
.catch((error) => reject(error));
|
||||
});
|
||||
};
|
||||
|
||||
const setStartProcessing = () => {
|
||||
return setProcessingValue(true);
|
||||
};
|
||||
|
||||
const setDoneProcessing = () => {
|
||||
return setProcessingValue(false);
|
||||
};
|
||||
|
||||
const checkIfProcessing = () => {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.processing.findAll()
|
||||
.then((results) => {
|
||||
if (results && results.length > 0){
|
||||
resolve(results[0].getDataValue('processing'));
|
||||
}else{
|
||||
db.processing.bulkCreate([{processing: false}])
|
||||
.then(() => {
|
||||
resolve(false);
|
||||
})
|
||||
.catch((error) => reject(error));
|
||||
}
|
||||
})
|
||||
.catch((error) => reject(error));
|
||||
});
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
setStartProcessing,
|
||||
setDoneProcessing,
|
||||
checkIfProcessing
|
||||
};
|
||||
Reference in New Issue
Block a user