From 0cb6adf5c743dbf9ddf505b71dba1f26902f7732 Mon Sep 17 00:00:00 2001 From: emilschn Date: Fri, 2 Feb 2024 14:28:37 +0100 Subject: [PATCH 1/3] fix query with is_usager_abandon_procedure NULL #2181 --- src/Repository/SuiviRepository.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Repository/SuiviRepository.php b/src/Repository/SuiviRepository.php index ba283c67b..a47ffc291 100755 --- a/src/Repository/SuiviRepository.php +++ b/src/Repository/SuiviRepository.php @@ -221,7 +221,7 @@ public function findSignalementsLastSuiviPublic( ) su ON s.id = su.signalement_id WHERE s.statut NOT IN (:status_need_validation, :status_closed, :status_archived, :status_refused) AND s.is_imported != 1 - AND s.is_usager_abandon_procedure != 1 + AND (s.is_usager_abandon_procedure != 1 OR s.is_usager_abandon_procedure IS NULL) GROUP BY s.id HAVING DATEDIFF(NOW(), IFNULL(last_posted_at, s.created_at)) > :day_period ORDER BY last_posted_at'; @@ -257,7 +257,7 @@ public function findSignalementsLastSuiviTechnical( WHERE su_last.id IS NULL AND su.max_date_suivi_technique < DATE_SUB(NOW(), INTERVAL :day_period DAY) AND s.statut NOT IN (:status_need_validation, :status_closed, :status_archived, :status_refused) AND s.is_imported != 1 - AND s.is_usager_abandon_procedure != 1'; + AND (s.is_usager_abandon_procedure != 1 OR s.is_usager_abandon_procedure IS NULL)'; $statement = $connection->prepare($sql); @@ -344,7 +344,7 @@ public function getSignalementsLastSuivisTechnicalsQuery( } if ($excludeUsagerAbandonProcedure) { - $whereExcludeUsagerAbandonProcedure = 'AND s.is_usager_abandon_procedure != 1 '; + $whereExcludeUsagerAbandonProcedure = 'AND (s.is_usager_abandon_procedure != 1 OR s.is_usager_abandon_procedure IS NULL)'; } if ($dayPeriod > 0) { $whereLastSuiviDelay = 'AND su.max_date_suivi < DATE_SUB(NOW(), INTERVAL '.$dayPeriod.' DAY) '; From daec55ee7e4482c98efb51d8bcd134c7b03ec889 Mon Sep 17 00:00:00 2001 From: emilschn Date: Fri, 2 Feb 2024 15:41:15 +0100 Subject: [PATCH 2/3] add limit to query #2181 --- src/Entity/Suivi.php | 1 + src/Repository/SuiviRepository.php | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Entity/Suivi.php b/src/Entity/Suivi.php index 71dc317c5..56f8c1765 100755 --- a/src/Entity/Suivi.php +++ b/src/Entity/Suivi.php @@ -18,6 +18,7 @@ class Suivi public const DEFAULT_PERIOD_INACTIVITY = 30; public const DEFAULT_PERIOD_RELANCE = 45; + public const LIMIT_DAILY_RELANCES = 45; public const DESCRIPTION_MOTIF_CLOTURE_ALL = 'Le signalement a été cloturé pour tous'; public const DESCRIPTION_MOTIF_CLOTURE_PARTNER = 'Le signalement a été cloturé pour'; diff --git a/src/Repository/SuiviRepository.php b/src/Repository/SuiviRepository.php index a47ffc291..975086f58 100755 --- a/src/Repository/SuiviRepository.php +++ b/src/Repository/SuiviRepository.php @@ -199,6 +199,7 @@ private function getSignalementsQuery( public function findSignalementsLastSuiviPublic( int $period = Suivi::DEFAULT_PERIOD_RELANCE, + int $limit = Suivi::LIMIT_DAILY_RELANCES, ): array { $connection = $this->getEntityManager()->getConnection(); @@ -224,7 +225,8 @@ public function findSignalementsLastSuiviPublic( AND (s.is_usager_abandon_procedure != 1 OR s.is_usager_abandon_procedure IS NULL) GROUP BY s.id HAVING DATEDIFF(NOW(), IFNULL(last_posted_at, s.created_at)) > :day_period - ORDER BY last_posted_at'; + ORDER BY last_posted_at + LIMIT '.$limit; $statement = $connection->prepare($sql); @@ -233,6 +235,7 @@ public function findSignalementsLastSuiviPublic( public function findSignalementsLastSuiviTechnical( int $period = Suivi::DEFAULT_PERIOD_INACTIVITY, + int $limit = Suivi::LIMIT_DAILY_RELANCES, ): array { $connection = $this->getEntityManager()->getConnection(); @@ -257,7 +260,8 @@ public function findSignalementsLastSuiviTechnical( WHERE su_last.id IS NULL AND su.max_date_suivi_technique < DATE_SUB(NOW(), INTERVAL :day_period DAY) AND s.statut NOT IN (:status_need_validation, :status_closed, :status_archived, :status_refused) AND s.is_imported != 1 - AND (s.is_usager_abandon_procedure != 1 OR s.is_usager_abandon_procedure IS NULL)'; + AND (s.is_usager_abandon_procedure != 1 OR s.is_usager_abandon_procedure IS NULL) + LIMIT '.$limit; $statement = $connection->prepare($sql); From 46f08776dce34351c643d4d88e74a73f215efa82 Mon Sep 17 00:00:00 2001 From: emilschn Date: Fri, 2 Feb 2024 15:54:37 +0100 Subject: [PATCH 3/3] fix limit to query #2181 --- src/Entity/Suivi.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Entity/Suivi.php b/src/Entity/Suivi.php index 56f8c1765..3fa262975 100755 --- a/src/Entity/Suivi.php +++ b/src/Entity/Suivi.php @@ -18,7 +18,7 @@ class Suivi public const DEFAULT_PERIOD_INACTIVITY = 30; public const DEFAULT_PERIOD_RELANCE = 45; - public const LIMIT_DAILY_RELANCES = 45; + public const LIMIT_DAILY_RELANCES = 400; public const DESCRIPTION_MOTIF_CLOTURE_ALL = 'Le signalement a été cloturé pour tous'; public const DESCRIPTION_MOTIF_CLOTURE_PARTNER = 'Le signalement a été cloturé pour';