Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Relances auto] Correction requête pour ne pas exclure les abandons de procédures NULL #2206

Merged
merged 3 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Entity/Suivi.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Suivi

public const DEFAULT_PERIOD_INACTIVITY = 30;
public const DEFAULT_PERIOD_RELANCE = 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';
Expand Down
12 changes: 8 additions & 4 deletions src/Repository/SuiviRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -221,10 +222,11 @@ 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';
ORDER BY last_posted_at
LIMIT '.$limit;

$statement = $connection->prepare($sql);

Expand All @@ -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();

Expand All @@ -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';
AND (s.is_usager_abandon_procedure != 1 OR s.is_usager_abandon_procedure IS NULL)
LIMIT '.$limit;

$statement = $connection->prepare($sql);

Expand Down Expand Up @@ -344,7 +348,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) ';
Expand Down
Loading