Skip to content

Commit

Permalink
Merge pull request #1515 from MTES-MCT/hotfix/1499-bo-premiere-relanc…
Browse files Browse the repository at this point in the history
…e-auto

[Relance auto] Correction sur la requête de première relance pour inclure les signalements n'ayant jamais eu ni suivi technique, ni suivi public
  • Loading branch information
sfinx13 authored Jul 26, 2023
2 parents a622fe8 + 7d5a6d5 commit fb38042
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 18 deletions.
44 changes: 44 additions & 0 deletions src/DataFixtures/Files/Signalement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1329,6 +1329,50 @@ signalements:
nb_occupants_logement: 3
situation_occupant: "1"
territory: "Bouches-du-Rhône"
tags:
- "Urgent"
situations:
- "la vie commune et le voisinage"
- "la sécurité des occupants"
- "l'état et propreté du logement"
criteres:
- "Les déchets sont mal stockés."
- "La protection incendie n’est pas adaptée."
- "Les sols sont humides."
criticites:
- "les déchets ne peuvent être stockés nulle part. Il y a des ordures stockées n’importe où à l'intérieur ou à l'extérieur du bâtiment."
- "il n’y a pas de détecteur OU l’évacuation du logement est complexe (une seule sortie étroite, étage élevé, absence de fenêtre, escalier peu praticable…)."
- "le sol ou la base des murs est très humide."
-
uuid: "00000000-0000-0000-2023-000000000020"
details: "Signalement ancien sans suivi"
is_proprio_averti: 1
is_logement_social: 0
nb_adultes: "2"
is_allocataire: ""
nature_logement: "Appartement"
type_logement: "T2"
superficie: 30
loyer: 300
phone_number: 0621127286
adresse_occupant: "7 Av. Rostand"
cp_occupant: "13003"
ville_occupant: "Marseille"
statut: 2
reference: "2023-20"
geoloc: "{\"lng\":\"43.3117791\",\"lat\":\"5.3755551\"}"
created_at: "2023-01-08 17:06:33"
score: 100
etage_occupant: "0"
escalier_occupant: ""
mode_contact_proprio: "[\"\",\"t\\u00e9l\\u00e9phone\"]"
insee_occupant: "13203"
is_rsa: 0
type_energie_logement: "Electrique"
origine_signalement: ""
nb_occupants_logement: 3
situation_occupant: "1"
territory: "Bouches-du-Rhône"
tags:
- "Urgent"
situations:
Expand Down
18 changes: 11 additions & 7 deletions src/Repository/SuiviRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,19 @@ public function findSignalementsLastSuiviPublic(
'status_refused' => Signalement::STATUS_REFUSED,
];

$sql = 'SELECT su.signalement_id, MAX(su.created_at) as last_posted_at
FROM suivi su
INNER JOIN signalement s on s.id = su.signalement_id
WHERE (su.type = :type_suivi_technical OR su.is_public = 1)
AND s.statut NOT IN (:status_need_validation, :status_closed, :status_archived, :status_refused)
$sql = 'SELECT s.id, s.created_at, MAX(su.max_date_suivi_technique_or_public) AS last_posted_at
FROM signalement s
LEFT JOIN (
SELECT signalement_id, MAX(created_at) AS max_date_suivi_technique_or_public
FROM suivi
WHERE (type = :type_suivi_technical OR is_public = 1)
GROUP BY signalement_id
) 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
GROUP BY su.signalement_id
HAVING DATEDIFF(NOW(),last_posted_at) > :day_period
GROUP BY s.id
HAVING DATEDIFF(NOW(), IFNULL(last_posted_at, s.created_at)) > :day_period
ORDER BY last_posted_at';

$statement = $connection->prepare($sql);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testDisplayMessageSuccessfullyForDebug(): void
$commandTester->assertCommandIsSuccessful();

$output = $commandTester->getDisplay();
$this->assertStringContainsString('4 signalement(s) for which a request for feedback will be sent', $output);
$this->assertStringContainsString('5 signalement(s) for which a request for feedback will be sent', $output);
$this->assertEmailCount(0);
}

Expand All @@ -43,7 +43,7 @@ public function testDisplayMessageSuccessfully(): void
$output = $commandTester->getDisplay();
$this->assertStringContainsString('1 signalement(s) for which the two last suivis are technicals ', $output);
$this->assertStringContainsString('1 signalement(s) for which the last suivi is technical', $output);
$this->assertStringContainsString('2 signalement(s) without suivi public', $output);
$this->assertEmailCount(5); // with cron notification email (4+1)
$this->assertStringContainsString('3 signalement(s) without suivi public', $output);
$this->assertEmailCount(6); // with cron notification email (4+1)
}
}
12 changes: 6 additions & 6 deletions tests/Functional/Controller/BackStatistiquesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,20 @@ public function testStatistiquesHomepage(string $route, string $email): void
public function provideRoutesStatistiquesDatas(): \Generator
{
yield 'Super Admin' => ['back_statistiques_filter', [], self::USER_SUPER_ADMIN, [
['result' => 31, 'label' => 'count_signalement'],
['result' => 70.6, 'label' => 'average_criticite'],
['result' => 32, 'label' => 'count_signalement'],
['result' => 71.5, 'label' => 'average_criticite'],
]];
yield 'Responsable Territoire' => ['back_statistiques_filter', [], self::USER_ADMIN_TERRITOIRE, [
['result' => 21, 'label' => 'count_signalement'],
['result' => 98.1, 'label' => 'average_criticite'],
['result' => 22, 'label' => 'count_signalement'],
['result' => 98.2, 'label' => 'average_criticite'],
]];
yield 'Partner' => ['back_statistiques_filter', [], self::USER_PARTNER, [
['result' => 3, 'label' => 'count_signalement'],
['result' => 100, 'label' => 'average_criticite'],
]];
yield 'RT - filtered with commune Arles' => ['back_statistiques_filter', ['communes' => '["Arles"]'], self::USER_ADMIN_TERRITOIRE, [
['result' => 21, 'label' => 'count_signalement'],
['result' => 98.1, 'label' => 'average_criticite'],
['result' => 22, 'label' => 'count_signalement'],
['result' => 98.2, 'label' => 'average_criticite'],
['result' => 0, 'label' => 'count_signalement_filtered'],
['result' => 0, 'label' => 'average_criticite_filtered'],
]];
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Controller/SignalementListControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ public function testSearchSignalementByTerms(string $filter, string|array $terms
public function provideFilterSearch(): \Generator
{
yield 'Search Terms with Reference' => ['bo-filters-searchterms', '2022-1', '1 signalement(s)'];
yield 'Search Terms with cp Occupant' => ['bo-filters-searchterms', '13003', '9 signalement(s)'];
yield 'Search Terms with cp Occupant' => ['bo-filters-searchterms', '13003', '10 signalement(s)'];
yield 'Search Terms with cp Occupant 13005' => ['bo-filters-searchterms', '13005', '3 signalement(s)'];
yield 'Search Terms with city Occupant' => ['bo-filters-searchterms', 'Gex', '5 signalement(s)'];
yield 'Search by Territory' => ['bo-filters-territories', ['1'], '5 signalement(s)'];
yield 'Search by Partner' => ['bo-filters-partners', ['5'], '2 signalement(s)'];
yield 'Search by Critere' => ['bo-filters-criteres', ['17'], '22 signalement(s)'];
yield 'Search by Critere' => ['bo-filters-criteres', ['17'], '23 signalement(s)'];
yield 'Search by Tags' => ['bo-filters-tags', ['3'], '4 signalement(s)'];
yield 'Search by Parc public/prive' => ['bo-filters-housetypes', ['1'], '4 signalement(s)'];
yield 'Search by Relances usagers' => ['bo-filters-relances_usager', ['NO_SUIVI_AFTER_3_RELANCES'], '1 signalement(s)'];
Expand Down

0 comments on commit fb38042

Please sign in to comment.