Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sorties pour ft #281

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

candidats pk ? Candidats parce que mdrrrrr

Copy link
Contributor

@YannickPassa YannickPassa May 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quand je quitterai le gip j'espere que mon futur employeur ira voir mes commentaires de PR avant de m'embaucher

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😭😭😭 que de rigolades entre les pk et les fdp

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Attention dans la table pass agréments il y a des doublons, peut etre que ça vaudrait le coup de les retirer

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
15 changes: 15 additions & 0 deletions dbt/models/marts/oneshot/motif_sortie_contrat_termine.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
select
emi.emi_pph_id as pph_id,
emi.emi_ctr_id as ctr_id,
emi.emi_date_fin_reelle as date_fin_reelle,
rms.rms_libelle as motif_de_sortie
from {{ ref("fluxIAE_EtatMensuelIndiv_v2") }} as emi
left join {{ ref("fluxIAE_RefMotifSort_v2") }} as rms
on emi.emi_motif_sortie_id = rms.rms_id
where emi.emi_date_fin_reelle is not null
group by
emi.emi_pph_id,
emi.emi_ctr_id,
emi.emi_date_fin_reelle,
emi.emi_motif_sortie_id,
rms.rms_libelle
9 changes: 9 additions & 0 deletions dbt/models/marts/oneshot/properties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ models:
- name: atigip_2022
description: >
Suivi des prescriptions des SPIP en 2022 pour l'ATIGIP.
Table créée à la demande de l'ATIGIP pour suivre les prescriptions des SPIPs.
Focus sur 2022 donc table fixe, mais rangée dans le dossier marts car mis à dispo sur Metabase pour le partage avec ATIGIP.
- name: candidatures_convergence
description: >
Suivi des candidatures réalisées par les ACI de Convergence.
Expand All @@ -19,3 +21,10 @@ models:
- name: motif_sortie_contrat_termine
description: >
Contient les dates et motifs de sortie pour les candidats à l'IAE. Permet de récupérer les dates de sortie des candidats de l'XP Nord pour permettre à FT de nous fournir la donnée sortie via la DSN.
- name: sorties_definitives
description: >
Table qui contient les dates de sorties pour chaque contrat du fluxiae.
Sert à obtenir les sorties pour l'expé nord france travail (table ft_candidats_sorties)
- name: ft_candidats_sorties
description: >
Contient les données candidats + les dates de sorties de ces candidats.
14 changes: 14 additions & 0 deletions dbt/models/marts/oneshot/sorties_definitives.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
select
ctr.contrat_id_pph,
ctr.contrat_id_structure,
ref_mesure.type_structure_emplois as type_structure,
max(ctr.contrat_date_sortie_definitive) as date_sortie
-- array_agg(motif_sortie.rms_libelle) as motifs_sortie
from {{ ref('fluxIAE_ContratMission_v2') }} as ctr
left join {{ ref('ref_mesure_dispositif_asp') }} as ref_mesure
on ref_mesure.af_mesure_dispositif_code = ctr.contrat_mesure_disp_code
where ctr.contrat_date_sortie_definitive is not null
group by
ctr.contrat_id_pph,
ctr.contrat_id_structure,
ref_mesure.type_structure_emplois
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'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flute je viens de voir ça...
La tu as pris les salariés habitant dans le 59 mais peut etre que tu as des salariés dans un département limitrophe et qui travaillent dans le 59. On est surs qu'on les veut pas ceux là ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oopsie... zut je vais voir avec aurélie merci j'y avais pas pensé

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
25 changes: 25 additions & 0 deletions scripts/sql/xpnord_sorties_avec_nir.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
select
ft.id_salarie_asp,
ft.id_salarie_emplois,
ft.date_sortie,
ft.type_structure,
ft.motif_de_sortie,
nir_corresp.nir,
case when nir_hash is not null then 'oui' else 'non' end as ft
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
ft.id_salarie_asp,
ft.id_salarie_emplois,
ft.date_sortie,
ft.type_structure,
ft.motif_de_sortie,
nir_corresp.nir
case when nir_hash is not null then 'oui' else 'non' end as ft
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
Loading