Skip to content

Commit 9e69248

Browse files
Corrige gestion migrants dans operations_stats
1 parent 16c2517 commit 9e69248

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

airflow/dags/secmar_checks.py

+7
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,13 @@ def checks():
146146
from operations
147147
where "cross" in ('Antilles-Guyane', 'Guadeloupe', 'Guyane', 'La Réunion', 'Martinique', 'Mayotte', 'Nouvelle-Calédonie', 'Polynésie') and (est_metropolitain or est_metropolitain is null)
148148
""",
149+
"operations_stats_migrant_avec_clandestins": """
150+
select count(1) = 0
151+
from operations as op
152+
join operations_stats as stats on stats.operation_id = op.operation_id
153+
join resultats_humain rh on rh.operation_id = op.operation_id and rh.categorie_personne = 'Migrant'
154+
where not stats.avec_clandestins
155+
""",
149156
}
150157

151158

opendata/sql/insert_operations_stats.sql

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ select
1717
null phase_journee,
1818
false concerne_snosan,
1919
false concerne_plongee,
20-
coalesce(rh.nombre_personnes_impliquees, 0) > coalesce(rh.nombre_personnes_impliquees_sans_clandestins, 0) avec_clandestins,
20+
coalesce(rh.nombre_personnes_impliquees, 0) >= coalesce(rh.nombre_personnes_impliquees_sans_clandestins, 0) avec_clandestins,
2121
op.distance_cote_metres distance_cote_metres,
2222
op.distance_cote_milles_nautiques distance_cote_milles_nautiques,
2323
op.est_dans_stm est_dans_stm,
@@ -96,10 +96,8 @@ left join (
9696
t.*,
9797
(nombre_personnes_decedees + nombre_personnes_decedees_naturellement + nombre_personnes_decedees_accidentellement) nombre_personnes_tous_deces,
9898
(nombre_personnes_decedees + nombre_personnes_decedees_naturellement + nombre_personnes_decedees_accidentellement + nombre_personnes_disparues) nombre_personnes_tous_deces_ou_disparues,
99-
(nombre_personnes_assistees + nombre_personnes_decedees + nombre_personnes_decedees_naturellement + nombre_personnes_decedees_accidentellement + nombre_personnes_disparues + nombre_personnes_impliquees_dans_fausse_alerte + nombre_personnes_retrouvees + nombre_personnes_secourues + nombre_personnes_tirees_daffaire_seule) nombre_personnes_impliquees,
10099
(nombre_personnes_decedees_sans_clandestins + nombre_personnes_decedees_naturellement_sans_clandestins + nombre_personnes_decedees_accidentellement_sans_clandestins) nombre_personnes_tous_deces_sans_clandestins,
101-
(nombre_personnes_decedees_sans_clandestins + nombre_personnes_decedees_naturellement_sans_clandestins + nombre_personnes_decedees_accidentellement_sans_clandestins + nombre_personnes_disparues_sans_clandestins) nombre_personnes_tous_deces_ou_disparues_sans_clandestins,
102-
(nombre_personnes_assistees_sans_clandestins + nombre_personnes_decedees_sans_clandestins + nombre_personnes_decedees_naturellement_sans_clandestins + nombre_personnes_decedees_accidentellement_sans_clandestins + nombre_personnes_disparues_sans_clandestins + nombre_personnes_impliquees_dans_fausse_alerte_sans_clandestins + nombre_personnes_retrouvees_sans_clandestins + nombre_personnes_secourues_sans_clandestins + nombre_personnes_tirees_daffaire_seule_sans_clandestins) nombre_personnes_impliquees_sans_clandestins
100+
(nombre_personnes_decedees_sans_clandestins + nombre_personnes_decedees_naturellement_sans_clandestins + nombre_personnes_decedees_accidentellement_sans_clandestins + nombre_personnes_disparues_sans_clandestins) nombre_personnes_tous_deces_ou_disparues_sans_clandestins
103101
from (
104102
select
105103
rh.operation_id,
@@ -122,7 +120,9 @@ left join (
122120
sum(case when categorie_personne not in ('Clandestin', 'Migrant') and resultat_humain = 'Personne impliquée dans fausse alerte' then nombre else 0 end) nombre_personnes_impliquees_dans_fausse_alerte_sans_clandestins,
123121
sum(case when categorie_personne not in ('Clandestin', 'Migrant') and resultat_humain = 'Personne retrouvée' then nombre else 0 end) nombre_personnes_retrouvees_sans_clandestins,
124122
sum(case when categorie_personne not in ('Clandestin', 'Migrant') and resultat_humain = 'Personne secourue' then nombre else 0 end) nombre_personnes_secourues_sans_clandestins,
125-
sum(case when categorie_personne not in ('Clandestin', 'Migrant') and resultat_humain = 'Personne tirée d''affaire seule' then nombre else 0 end) nombre_personnes_tirees_daffaire_seule_sans_clandestins
123+
sum(case when categorie_personne not in ('Clandestin', 'Migrant') and resultat_humain = 'Personne tirée d''affaire seule' then nombre else 0 end) nombre_personnes_tirees_daffaire_seule_sans_clandestins,
124+
sum(case when categorie_personne in ('Clandestin', 'Migrant') then 0 else nombre end) nombre_personnes_impliquees_sans_clandestins,
125+
sum(nombre) nombre_personnes_impliquees
126126
from resultats_humain rh
127127
group by rh.operation_id
128128
) t

0 commit comments

Comments
 (0)