From cdb9f372cf350712aae9f15e8c4bc5d411e48cb4 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 8 Mar 2024 12:19:57 +0100 Subject: [PATCH 1/3] feat: refs #6610 fixDeleteTickets --- db/routines/vn/procedures/clean.sql | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 06f36afce..e31d73c14 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -182,6 +182,27 @@ BEGIN DELETE FROM travelLog WHERE creationDate < v3Month; + CREATE OR REPLACE TEMPORARY TABLE tTicketDelete + SELECT DISTINCT tl.originFk ticketFk, sub.ticketFk aa + FROM ticketLog tl + JOIN ( + SELECT MAX(tl.id)ids,tw.ticketFk + FROM ticket t + JOIN ticketLog tl ON tl.originFk = t.id + LEFT JOIN ticketWeekly tw ON tw.ticketFk =t.id + WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31' + AND t.isDeleted + AND tw.ticketFk IS NULL + GROUP BY t.id + ) sub ON sub.ids = tl.id + WHERE tl.creationDate <= util.VN_CURDATE() - INTERVAL 60 DAY; + + DELETE t + FROM ticket t + JOIN tTicketDelete tmp ON tmp.ticketFk = t.id; + + DROP TEMPORARY TABLE tTicketDelete; + CALL shelving_clean; DELETE FROM chat WHERE dated < v5Years; -- 2.40.1 From b1e90fabb2346933518134efd8745a043fa911d1 Mon Sep 17 00:00:00 2001 From: robert Date: Fri, 8 Mar 2024 12:32:22 +0100 Subject: [PATCH 2/3] refs #6610 --- db/routines/vn/procedures/clean.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index e31d73c14..66164d894 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -183,19 +183,19 @@ BEGIN DELETE FROM travelLog WHERE creationDate < v3Month; CREATE OR REPLACE TEMPORARY TABLE tTicketDelete - SELECT DISTINCT tl.originFk ticketFk, sub.ticketFk aa + SELECT DISTINCT tl.originFk ticketFk FROM ticketLog tl JOIN ( - SELECT MAX(tl.id)ids,tw.ticketFk + SELECT MAX(tl.id)ids, tw.ticketFk FROM ticket t JOIN ticketLog tl ON tl.originFk = t.id LEFT JOIN ticketWeekly tw ON tw.ticketFk =t.id - WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31' + WHERE t.shipped BETWEEN '2000-01-01' AND '2000-12-31' AND t.isDeleted AND tw.ticketFk IS NULL GROUP BY t.id - ) sub ON sub.ids = tl.id - WHERE tl.creationDate <= util.VN_CURDATE() - INTERVAL 60 DAY; + ) sub ON sub.ids = tl.id + WHERE tl.creationDate <= vDateShort; DELETE t FROM ticket t -- 2.40.1 From 9910ae5c643b51369d5e7b0036046f4f2c3fca6d Mon Sep 17 00:00:00 2001 From: robert Date: Mon, 11 Mar 2024 12:12:02 +0100 Subject: [PATCH 3/3] fix: refs #6610 quitar variable --- db/routines/vn/procedures/clean.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/routines/vn/procedures/clean.sql b/db/routines/vn/procedures/clean.sql index 66164d894..cee64d772 100644 --- a/db/routines/vn/procedures/clean.sql +++ b/db/routines/vn/procedures/clean.sql @@ -186,7 +186,7 @@ BEGIN SELECT DISTINCT tl.originFk ticketFk FROM ticketLog tl JOIN ( - SELECT MAX(tl.id)ids, tw.ticketFk + SELECT MAX(tl.id)ids FROM ticket t JOIN ticketLog tl ON tl.originFk = t.id LEFT JOIN ticketWeekly tw ON tw.ticketFk =t.id -- 2.40.1