From 849989afa87c5a80dcd025dc38e4dd746eca8984 Mon Sep 17 00:00:00 2001 From: sergiodt Date: Wed, 7 Aug 2024 08:19:44 +0200 Subject: [PATCH] feat workerActivity refs #6078 --- back/methods/workerActivity/add.js | 33 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/back/methods/workerActivity/add.js b/back/methods/workerActivity/add.js index bba05dafd..4592a0797 100644 --- a/back/methods/workerActivity/add.js +++ b/back/methods/workerActivity/add.js @@ -1,4 +1,3 @@ - module.exports = Self => { Self.remoteMethodCtx('add', { description: 'Add activity if the activity is different or is the same but have exceed time for break', @@ -31,23 +30,21 @@ module.exports = Self => { return await Self.rawSql(` INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model) - SELECT ?, - ?, - ? - FROM workerTimeControlParams wtcp - LEFT JOIN ( - SELECT wa.workerFk, - wa.created, - wat.code - FROM workerActivity wa - LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk - WHERE wa.workerFk = ? - ORDER BY wa.created DESC - LIMIT 1 - ) sub ON TRUE - WHERE sub.workerFk IS NULL - OR sub.code <> ? - OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` + SELECT ?, ?, ? + FROM workerTimeControlParams wtcp + LEFT JOIN ( + SELECT wa.workerFk, + wa.created, + wat.code + FROM workerActivity wa + LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk + WHERE wa.workerFk = ? + ORDER BY wa.created DESC + LIMIT 1 + ) sub ON TRUE + WHERE sub.workerFk IS NULL + OR sub.code <> ? + OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;` , [userId, code, model, userId, code], myOptions); }; };