Skip to content

Commit

Permalink
clean orga
Browse files Browse the repository at this point in the history
  • Loading branch information
laurinehu committed May 13, 2024
1 parent 400b82b commit fba4078
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 62 deletions.
10 changes: 10 additions & 0 deletions dbt/models/marts/daily/candidats_pk.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
select
salarie_asp."hash_numéro_pass_iae" as "hash_numéro_pass_iae",
salarie_asp.salarie_id as id_salarie_asp,
candidat_emploi.id as id_candidat_emplois,
candidat_emploi.hash_nir as hash_nir
from {{ source('fluxIAE', 'fluxIAE_Salarie') }} as salarie_asp
left join {{ source('emplois', 'pass_agréments') }} as pass
on salarie_asp."hash_numéro_pass_iae" = pass."hash_numéro_pass_iae"
left join {{ ref('candidats') }} as candidat_emploi
on candidat_emploi.id = pass.id_candidat
32 changes: 0 additions & 32 deletions dbt/models/marts/oneshot/ft_candidats_non_ft_sorties.sql

This file was deleted.

24 changes: 0 additions & 24 deletions dbt/models/marts/oneshot/ft_candidats_sorties.sql

This file was deleted.

30 changes: 30 additions & 0 deletions dbt/models/marts/oneshot/xpnord_sorties_candidats_asp.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
select
candidats.hash_nir as nir_emplois,
ft_candidats.nir_hash as nir_ft,
candidats.id_candidat_emplois as id_candidat_emplois,
candidats.id_salarie_asp as id_salarie_asp,
sorties.date_sortie,
sorties.type_structure,
msct.motif_de_sortie
from {{ ref('candidats_pk') }} as candidats
left join {{ ref('fluxIAE_Salarie_v2') }} as salarie_asp
on salarie_asp.salarie_id = candidats.id_salarie_asp
left join {{ source('emplois', 'pass_agréments') }} as pass
on pass."hash_numéro_pass_iae" = candidats."hash_numéro_pass_iae"
-- pour filtrer les candidats non ft
left join {{ ref('ft_candidats_nord') }} as ft_candidats
on ft_candidats.nir_hash = candidats.hash_nir
-- pour récupérer la sortie
left join {{ ref('sorties_definitives') }} as sorties
on sorties.contrat_id_pph = candidats.id_salarie_asp
-- pour récupérer le motif de sortie
left join {{ ref('motif_sortie_contrat_termine') }} as msct
on sorties.contrat_id_pph = msct.pph_id and sorties.date_sortie = msct.date_fin_reelle
-- on ne garde que les candidats :
-- - du nord
-- - un pass IAE a été attribué entre le 1 janvier 2021 et le 30 juin 2023.
where
salarie_asp.salarie_code_dpt = '059'
and pass."date_début" > '2021-01-01'
and pass."date_début" < '2023-06-30'
and sorties.date_sortie is not null
18 changes: 18 additions & 0 deletions dbt/models/marts/oneshot/xpnord_sorties_candidats_ft.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
select
candidats.hash_nir as nir_emplois,
ft_candidats.nir_hash as nir_ft,
candidats.id_candidat_emplois as id_candidat_emplois,
candidats.id_salarie_asp as id_salarie_asp,
sorties.date_sortie,
sorties.type_structure,
msct.motif_de_sortie
from {{ source('oneshot', 'ft_iae_nord') }} as ft_candidats
left join {{ ref('candidats_pk') }} as candidats
on candidats.hash_nir = ft_candidats.nir_hash
-- ici on croise avec les sorties définitives
-- duplication des candidats parceque certains candidats ont plusieurs sorties
left join {{ ref('sorties_definitives') }} as sorties
on sorties.contrat_id_pph = candidats.id_salarie_asp
-- pour récupérer le motif de sortie
left join {{ ref('motif_sortie_contrat_termine') }} as msct
on sorties.contrat_id_pph = msct.pph_id and sorties.date_sortie = msct.date_fin_reelle
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ select
ft.date_sortie,
ft.type_structure,
ft.motif_de_sortie,
-- ajouter ici la colonne nir récupérée de la jointure
nir_corresp.nir,
case when nir_hash is not null then 'oui' else 'non' end as ft
from {{ ref("ft_candidats_sorties") }} as ft
-- ajouter ici un left join sur la table de correspondance nir/id_salarie
from {{ ref("xpnord_sorties_candidats_ft") }} as ft
left join {{ ref("nir_corresp") }} as nir_corresp
on nir_corresp.hash_nir = ft.nir_ft
where ft.date_sortie is not null
union
select
Expand All @@ -16,8 +17,9 @@ select
ft.date_sortie,
ft.type_structure,
ft.motif_de_sortie,
-- ajouter ici la colonne nir récupérée de la jointure
nir_corresp.nir
case when nir_hash is not null then 'oui' else 'non' end as ft
from {{ ref("ft_candidats_non_ft_sorties") }} as ft
-- ajouter ici un left join sur la table de correspondance nir/id_salarie
from {{ ref("xpnord_sorties_candidats_asp") }} as ft
left join {{ ref("nir_corresp") }} as nir_corresp
on nir_corresp.hash_nir = ft.nir_emplois
where ft.date_sortie is not null

0 comments on commit fba4078

Please sign in to comment.