Queue transaction
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
ea6b1abdd8
commit
d156cb1c30
|
@ -15,7 +15,6 @@ module.exports = app => {
|
|||
WHERE at.id = ?`;
|
||||
|
||||
const auth = await db.findOne(query, [token]);
|
||||
console.log(auth);
|
||||
|
||||
if (!auth || isTokenExpired(auth.created, auth.ttl))
|
||||
throw new Error('Invalid authorization token');
|
||||
|
@ -32,8 +31,6 @@ module.exports = app => {
|
|||
locale: auth.lang
|
||||
};
|
||||
|
||||
console.log(response.locals.auth);
|
||||
|
||||
next();
|
||||
} catch (error) {
|
||||
next(error);
|
||||
|
|
|
@ -29,10 +29,14 @@ module.exports = async function(request, response, next) {
|
|||
LEFT JOIN account.emailUser eu ON eu.userFk = c.salesPersonFk
|
||||
WHERE status = ''`);
|
||||
|
||||
let connection;
|
||||
let invoiceId;
|
||||
for (const invoiceOut of invoices) {
|
||||
try {
|
||||
invoiceId = invoiceOut.id;
|
||||
connection = await db.getConnection();
|
||||
connection.query('START TRANSACTION');
|
||||
|
||||
const args = Object.assign({
|
||||
invoiceId: invoiceOut.id,
|
||||
recipientId: invoiceOut.clientFk,
|
||||
|
@ -57,7 +61,7 @@ module.exports = async function(request, response, next) {
|
|||
fileName: fileName
|
||||
});
|
||||
|
||||
await db.rawSql('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id]);
|
||||
connection.query('UPDATE invoiceOut SET hasPdf = true WHERE id = ?', [invoiceOut.id]);
|
||||
|
||||
const isToBeMailed = invoiceOut.recipient && invoiceOut.salesPersonFk && invoiceOut.isToBeMailed;
|
||||
|
||||
|
@ -93,8 +97,11 @@ module.exports = async function(request, response, next) {
|
|||
SET status = "printed",
|
||||
printed = NOW()
|
||||
WHERE invoiceFk = ?`;
|
||||
await db.rawSql(sql, [invoiceOut.id]);
|
||||
connection.query(sql, [invoiceOut.id]);
|
||||
connection.query('COMMIT');
|
||||
} catch (error) {
|
||||
connection.query('ROLLBACK');
|
||||
connection.release();
|
||||
sql = `UPDATE invoiceOut_queue
|
||||
SET status = ?
|
||||
WHERE invoiceFk = ?`;
|
||||
|
|
Loading…
Reference in New Issue