fix: solo un trabajador por fallo
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Javi Gallego 2024-03-26 08:52:01 +01:00
parent 2212899400
commit e47b8c1056
1 changed files with 16 additions and 10 deletions

View File

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