Skip to content

Commit 2a7cf6f

Browse files
Corrige gestion migrants dans operations_stats
1 parent 16c2517 commit 2a7cf6f

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

airflow/dags/secmar_checks.py

+12
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ def checks():
2727
from operations_points
2828
) operations_points on true
2929
""",
30+
"concerne_snosan_count_2020": """
31+
select count(1) between 9700 and 9800
32+
from operations_stats
33+
where annee = 2020 and concerne_snosan
34+
""",
3035
"concerne_snosan": """
3136
select
3237
nb_operations_snosan = nb_operations_concerne_snosan
@@ -146,6 +151,13 @@ def checks():
146151
from operations
147152
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)
148153
""",
154+
"operations_stats_migrant_avec_clandestins": """
155+
select count(1) = 0
156+
from operations as op
157+
join operations_stats as stats on stats.operation_id = op.operation_id
158+
join resultats_humain rh on rh.operation_id = op.operation_id and rh.categorie_personne = 'Migrant'
159+
where not stats.avec_clandestins
160+
""",
149161
}
150162

151163

opendata/sql/insert_operations_stats.sql

+4-4
Original file line numberDiff line numberDiff line change
@@ -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)