7199-devToTest_2316 #2287

Merged
alexm merged 169 commits from 7199-devToTest_2316 into test 2024-04-11 06:25:23 +00:00
1 changed files with 16 additions and 10 deletions
Showing only changes of commit 5a19c1ebb1 - Show all commits

View File

@ -34,16 +34,22 @@ BEGIN
-- Rellena la tabla tmp.errorsByChecker con fallos de revisores
CREATE OR REPLACE TEMPORARY TABLE tmp.errorsByChecker
ENGINE = MEMORY
SELECT st.workerFk,
COUNT(t.id) errors
FROM saleMistake sm
JOIN saleTracking st ON sm.saleFk = st.saleFk
JOIN `state` s2 ON s2.id = st.stateFk
JOIN sale s ON s.id = sm.saleFk
JOIN ticket t on t.id = s.ticketFk
WHERE (t.shipped BETWEEN vDatedFrom AND vDatedTo)
AND s2.code IN ('OK','PREVIOUS_PREPARATION','PREPARED','CHECKED')
GROUP BY st.workerFk;
WITH rankedWorkers AS (
SELECT sm.id,
st.workerFk,
ROW_NUMBER() OVER(PARTITION BY sm.id ORDER BY s2.`order`) rnk
FROM vn.saleMistake sm
JOIN vn.saleTracking st ON sm.saleFk = st.saleFk
JOIN vn.`state` s2 ON s2.id = st.stateFk
JOIN vn.sale s ON s.id = sm.saleFk
JOIN vn.ticket t ON t.id = s.ticketFk
WHERE t.shipped BETWEEN vDatedFrom AND vDatedTo
AND s2.code IN ('OK', 'PREVIOUS_PREPARATION', 'PREPARED', 'CHECKED')
)
SELECT workerFk, COUNT(*) errors
FROM rankedWorkers
WHERE rnk = 1
GROUP BY workerFk;
-- Rellena la tabla tmp.expeditionErrors con fallos de expediciones
CREATE OR REPLACE TEMPORARY TABLE tmp.expeditionErrors