-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3638 from MTES-MCT/hotfix/3635-prevent-doublon-su…
…ivi-intervention [BUG] doublonge des création de suivi pour arrétés au 29/01/2025
- Loading branch information
Showing
7 changed files
with
56 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DoctrineMigrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Doctrine\Migrations\AbstractMigration; | ||
|
||
final class Version20250129102407 extends AbstractMigration | ||
{ | ||
public function getDescription(): string | ||
{ | ||
return 'Add on delete cascade on notification suivi_id and delete suivis for arretes and visites created on 2025-01-29'; | ||
} | ||
|
||
public function up(Schema $schema): void | ||
{ | ||
// add on delete cascade on notification suivi_id | ||
$this->addSql('ALTER TABLE notification DROP FOREIGN KEY FK_BF5476CA7FEA59C0'); | ||
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA7FEA59C0 FOREIGN KEY (suivi_id) REFERENCES suivi (id) ON DELETE CASCADE'); | ||
// delete suivis for arretes and visites created on 2025-01-29 | ||
$this->addSql("DELETE FROM suivi WHERE description LIKE '%pris dans le dossier de%' AND context = 'intervention' AND created_at LIKE '2025-01-29%'"); | ||
$this->addSql("DELETE FROM suivi WHERE description LIKE 'Visite réalisée : une visite du logement situé%' AND context = 'intervention' AND created_at LIKE '2025-01-29%'"); | ||
} | ||
|
||
public function down(Schema $schema): void | ||
{ | ||
$this->addSql('ALTER TABLE notification DROP FOREIGN KEY FK_BF5476CA7FEA59C0'); | ||
$this->addSql('ALTER TABLE notification ADD CONSTRAINT FK_BF5476CA7FEA59C0 FOREIGN KEY (suivi_id) REFERENCES suivi (id)'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ public function testBuildVisiteDescription(): void | |
$eventDispatcher = new EventDispatcher(); | ||
$visiteNotifier = static::getContainer()->get(VisiteNotifier::class); | ||
$suiviManager = static::getContainer()->get(SuiviManager::class); | ||
$htmlSanitizer = self::getContainer()->get('html_sanitizer.sanitizer.app.message_sanitizer'); | ||
|
||
/** @var InterventionRepository $interventionRepository */ | ||
$interventionRepository = $this->entityManager->getRepository(Intervention::class); | ||
|
@@ -49,7 +50,7 @@ public function testBuildVisiteDescription(): void | |
/** @var UserRepository $userRepository */ | ||
$userRepository = $this->entityManager->getRepository(User::class); | ||
$user = $userRepository->findOneBy(['email' => '[email protected]']); | ||
$interventionCreatedSubscriber = new InterventionCreatedSubscriber($visiteNotifier, $suiviManager); | ||
$interventionCreatedSubscriber = new InterventionCreatedSubscriber($visiteNotifier, $suiviManager, $htmlSanitizer); | ||
$eventDispatcher->addSubscriber($interventionCreatedSubscriber); | ||
|
||
$intervention = $interventions[0]; | ||
|
@@ -100,6 +101,7 @@ private function testNbMailSent(\DateTimeImmutable $date, $type): void | |
$eventDispatcher = new EventDispatcher(); | ||
$visiteNotifier = static::getContainer()->get(VisiteNotifier::class); | ||
$suiviManager = static::getContainer()->get(SuiviManager::class); | ||
$htmlSanitizer = self::getContainer()->get('html_sanitizer.sanitizer.app.message_sanitizer'); | ||
|
||
/** @var InterventionRepository $interventionRepository */ | ||
$interventionRepository = $this->entityManager->getRepository(Intervention::class); | ||
|
@@ -111,7 +113,7 @@ private function testNbMailSent(\DateTimeImmutable $date, $type): void | |
/** @var UserRepository $userRepository */ | ||
$userRepository = $this->entityManager->getRepository(User::class); | ||
$user = $userRepository->findOneBy(['email' => '[email protected]']); | ||
$interventionCreatedSubscriber = new InterventionCreatedSubscriber($visiteNotifier, $suiviManager); | ||
$interventionCreatedSubscriber = new InterventionCreatedSubscriber($visiteNotifier, $suiviManager, $htmlSanitizer); | ||
$eventDispatcher->addSubscriber($interventionCreatedSubscriber); | ||
|
||
$intervention->setScheduledAt($date); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters