Skip to content

Commit

Permalink
last modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
laurinehu committed Oct 23, 2023
1 parent 6b6eae6 commit 65d8157
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 24 deletions.
41 changes: 41 additions & 0 deletions Untitled.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"id": "7332e7a3-9cb2-404f-af19-0b084f1b0ce4",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": null,
"id": "a2125a19-3c21-4f79-bff8-e99a91e0b1d1",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.9"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
14 changes: 2 additions & 12 deletions dbt/models/marts/candidatures_reseaux.sql
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
select
{{ pilo_star(ref('stg_candidatures'), relation_alias='candidatures') }},
{{ pilo_star(ref('stg_org_prescripteur'), except=["id_org"], relation_alias='org_prescripteur') }},
{{ pilo_star(ref('stg_bassin_emploi'), except=["nom_departement", "nom_region", "type_epci", "id_structure"],
relation_alias='bassin_emploi') }},
{{ pilo_star(ref('stg_reseaux'), except=["SIRET","id_structure"], relation_alias='rsx') }},
{{ pilo_star(ref('stg_reseaux'), except=["SIRET", "id_structure"], relation_alias='rsx') }},
case
when candidatures.injection_ai = 0 then 'Non'
else 'Oui'
end as reprise_de_stock_ai,
nom_org.type_auteur_diagnostic_detaille
end as reprise_de_stock_ai
from
{{ ref('stg_candidatures') }} as candidatures
left join {{ ref('stg_bassin_emploi') }} as bassin_emploi
on bassin_emploi.id_structure = candidatures.id_structure
left join {{ ref('stg_org_prescripteur') }} as org_prescripteur
on org_prescripteur.id_org = candidatures.id_org_prescripteur
left join {{ ref('nom_prescripteur') }} as nom_org
on nom_org.origine_detaille = candidatures."origine_détaillée"
left join {{ ref('stg_reseaux') }} as rsx
on candidatures.id_structure = rsx.id_structure
where candidatures.type_structure in ('AI', 'ACI', 'EITI', 'ETTI', 'EI')
9 changes: 9 additions & 0 deletions dbt/models/marts/properties.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,12 @@ models:
description: >
Table permettant de suivre les PASS IAE n'ayant jamais été associés à une demande de prolongation et ceux associés à une (ou plusieurs) demande de prolongation.
A noter, le même pass IAE peut avoir deux entrées dans cette table car une demande peut etre refusée, ce qui amène souvent à une nouvelle demande, qui elle peut être acceptée.
- name: suivi_cap_structures
description: >
Suivi des structures ayant fait l'objet du contrôle a posteriori. Table réalisée pour la réalisation du tb suivi du contrôle a posteriori.
- name: suivi_cap_critères
description: >
Suivi des critères vérifiés dans le cadre du contrôle a posteriori. Table réalisée pour la réalisation du tb suivi du contrôle a posteriori.
- name: suivi_cap
description: >
Contient les statistiques de contrôle des structures pour toutes les campagnes de contrôle. Table réalisée pour la réalisation du tb suivi du contrôle a posteriori.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ select
structs."département" as "département",
structs."nom_département" as "nom_département",
structs."région" as "nom_région",
structs.bassin_d_emploi as bassin_d_emploi,
structs."type" as "type_structure",
case
when
Expand Down Expand Up @@ -38,5 +39,5 @@ from
left join {{ source('emplois', 'critères_iae') }} as criteres on cap_criteres."id_critère_iae" = criteres."id"
left join {{ source('emplois', 'cap_candidatures') }} as candidatures on cap_criteres."id_cap_candidature" = candidatures."id"
left join {{ source('emplois', 'cap_structures') }} as cap_structs on candidatures."id_cap_structure" = cap_structs."id"
left join {{ source('emplois', 'structures') }} as structs on cap_structs."id_structure" = structs."id"
left join {{ ref('stg_structures') }} as structs on cap_structs."id_structure" = structs."id"
left join {{ source('emplois', 'cap_campagnes') }} as camp on cap_structs."id_cap_campagne" = camp."id"
3 changes: 2 additions & 1 deletion dbt/models/marts/suivi_cap_structures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ select
structures."département" as "département",
structures."nom_département" as "nom_département",
structures."région" as "région",
structures.bassin_d_emploi as bassin_d_emploi,
cap_structures."état" as "état",
cap_rep."réponse_au_contrôle" as "réponse_au_contrôle",
case
Expand All @@ -26,7 +27,7 @@ select
'Non'
end as "controlee"
from
{{ source('emplois', 'structures') }} as structures
{{ ref('stg_structures') }} as structures
left join {{ source('emplois', 'cap_structures') }} as cap_structures
on structures.id = cap_structures.id_structure
left join {{ source('emplois', 'cap_campagnes') }} as cap_campagnes
Expand Down
7 changes: 2 additions & 5 deletions dbt/models/staging/stg_candidatures.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ select
except=["id", "date_mise_à_jour_metabase", "état", "motif_de_refus", "origine", "délai_de_réponse", "délai_prise_en_compte", "origine_détaillée"]) }},
{{ pilo_star(ref('stg_organisations'), except=["id", "date_mise_à_jour_metabase", "ville", "code_commune", "type", "date_inscription", "total_candidatures", "total_membres", "total_embauches", "date_derniere_candidature"], relation_alias='org_prescripteur') }},
candidatures.id as id,
struct.code_commune as code_commune_structure,
insee_geo.nom_zone_emploi as bassin_emploi_structure,
struct.bassin_emploi_structure as bassin_emploi_structure,
org_prescripteur.zone_emploi as bassin_emploi_prescripteur,
org_prescripteur.type as type_org_prescripteur,
org_prescripteur.date_inscription as date_inscription_orga,
Expand All @@ -29,10 +28,8 @@ select
extract(day from candidatures."délai_prise_en_compte") as temps_de_prise_en_compte
from
{{ source('emplois', 'candidatures') }} as candidatures
left join {{ source('emplois', 'structures') }} as struct
left join {{ ref('stg_structures') }} as struct
on struct.id = candidatures.id_structure
left join {{ ref("stg_insee_appartenance_geo_communes") }} as insee_geo
on ltrim(struct.code_commune, '0') = insee_geo.code_insee
left join {{ ref('stg_organisations') }} as org_prescripteur
on org_prescripteur.id = candidatures.id_org_prescripteur
left join {{ ref('nom_prescripteur') }} as nom_org
Expand Down
14 changes: 9 additions & 5 deletions dbt/models/staging/stg_structures.sql
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
select
s.id as id,
s.siret as siret,
s.active as active,
s.ville as ville,
s.nom_complet as "nom_structure_complet"
s.id as id,
s.siret as siret,
s.active as active,
s.ville as ville,
insee_geo.nom_zone_emploi as bassin_emploi_structure,
s.nom_complet as "nom_structure_complet"
from
{{ source('emplois', 'structures') }} as s
left join
{{ ref('stg_insee_appartenance_geo_communes') }} as insee_geo
on ltrim(s.code_commune, '0') = insee_geo.code_insee

0 comments on commit 65d8157

Please sign in to comment.