-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(pipeline): add imilo as a new data source #365
base: main
Are you sure you want to change the base?
Changes from 1 commit
70f51b6
3d614fb
7dae2a1
1890a2c
acf2bee
5c0c1ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -8,23 +8,13 @@ models: | |||||||||||||
- unique | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- name: structure_id | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- relationships: | ||||||||||||||
to: ref('stg_imilo__structures') | ||||||||||||||
field: id | ||||||||||||||
- name: nom | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- name: date_maj | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.accepted_range: | ||||||||||||||
min_value: "now() - interval '2 years'" | ||||||||||||||
config: | ||||||||||||||
severity: warn | ||||||||||||||
- name: date_creation | ||||||||||||||
data_tests: | ||||||||||||||
- not_null: | ||||||||||||||
|
@@ -33,17 +23,42 @@ models: | |||||||||||||
- dbt_utils.not_constant | ||||||||||||||
- name: thematiques | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pour tous les champs qui sont supposés réutilisés nos référentiels, on peut vérifier que c'est le cas. e.g.
Suggested change
|
||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- relationships: | ||||||||||||||
to: ref('thematiques') | ||||||||||||||
field: value | ||||||||||||||
- name: presentation_resume | ||||||||||||||
data_tests: | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- name: modes_accueil | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- relationships: | ||||||||||||||
to: ref('modes_accueil') | ||||||||||||||
field: value | ||||||||||||||
- name: profils | ||||||||||||||
data_tests: | ||||||||||||||
- dbt_utils.expression_is_true: | ||||||||||||||
expression: "<@ ARRAY(SELECT value FROM {{ ref('profils') }})" | ||||||||||||||
- name: modes_orientation_beneficiaire | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- relationships: | ||||||||||||||
to: ref('modes_orientation_beneficiaire') | ||||||||||||||
field: value | ||||||||||||||
|
||||||||||||||
- name: stg_imilo__structures_offres | ||||||||||||||
columns: | ||||||||||||||
- name: id_offre | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- name: id_structure | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
|
||||||||||||||
- name: stg_imilo__structures | ||||||||||||||
columns: | ||||||||||||||
- name: id | ||||||||||||||
|
@@ -53,13 +68,15 @@ models: | |||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- name: courriel | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- name: antenne | ||||||||||||||
- name: siret | ||||||||||||||
data_tests: | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- name: commune | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.not_empty_string | ||||||||||||||
- name: horaires_ouverture | ||||||||||||||
data_tests: | ||||||||||||||
|
@@ -104,7 +121,3 @@ models: | |||||||||||||
- name: date_maj | ||||||||||||||
data_tests: | ||||||||||||||
- not_null | ||||||||||||||
- dbt_utils.accepted_range: | ||||||||||||||
min_value: "now() - interval '2 years'" | ||||||||||||||
config: | ||||||||||||||
severity: warn |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,34 +2,30 @@ WITH source AS ( | |
{{ stg_source_header('imilo', 'offres') }} | ||
), | ||
|
||
structures_offres AS ( | ||
SELECT | ||
CAST((data -> 'structures_offres' ->> 'offre_id') AS INTEGER) AS "id_offre", | ||
CAST((data -> 'structures_offres' ->> 'missionlocale_id') AS INTEGER) AS "id_structure", | ||
CONCAT( | ||
(data -> 'structures_offres' ->> 'offre_id'), | ||
'_', | ||
(data -> 'structures_offres' ->> 'missionlocale_id') | ||
) AS "offre_structure_id" | ||
FROM {{ source('imilo', 'structures_offres') }} | ||
), | ||
|
||
final AS ( | ||
SELECT | ||
source._di_source_id AS "_di_source_id", | ||
structures_offres."offre_structure_id" AS "id", | ||
NULLIF(TRIM(source.data -> 'offres' ->> 'id_offre'), '') AS "id", | ||
CAST((source.data -> 'offres' ->> 'date_maj') AS TIMESTAMP WITH TIME ZONE) AS "date_maj", | ||
NULLIF(TRIM(source.data -> 'offres' ->> 'nom_dora'), '') AS "nom", | ||
NULLIF(TRIM(source.data -> 'offres' ->> 'thematique'), '') AS "thematiques", | ||
CAST((source.data -> 'offres' ->> 'date_import') AS TIMESTAMP WITH TIME ZONE) AS "date_creation", | ||
NULLIF(TRIM(source.data -> 'offres' ->> 'description'), '') AS "presentation_resume", | ||
NULLIF(TRIM(source.data -> 'offres' ->> 'modes_accueil'), '') AS "modes_accueil", | ||
NULLIF(TRIM(source.data -> 'offres' ->> 'liste_des_profils'), '') AS "profils", | ||
NULLIF(TRIM(source.data -> 'offres' ->> 'modes_orientation_beneficiaire'), '') AS "modes_orientation_beneficiaire", | ||
CAST(structures_offres."id_structure" AS TEXT) AS "structure_id" | ||
CASE | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vmttn En fait ici je me dis que je pars déjà peut etre trop déjà dans le mapping mais ça avait l'avantage de permettre de tester si, lorsque de nouveaux profils seront ajoutés, ils matcheront bien notre référentiel |
||
WHEN source.data -> 'offres' ->> 'liste_des_profils' IS NULL THEN NULL | ||
ELSE ARRAY( | ||
SELECT | ||
CASE | ||
WHEN profils = 'Jeunes de 16 à 25 ans' THEN 'jeunes-16-26' | ||
WHEN profils = 'RQTH moins de 30 ans' THEN 'personnes-handicapees' | ||
ELSE profils -- original value if it doesn't match any pattern, then it should fail the test | ||
END | ||
FROM UNNEST(STRING_TO_ARRAY(source.data -> 'offres' ->> 'liste_des_profils', ';')) AS profils | ||
) | ||
END AS "profils", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @hlecuyer y a-t-il une petite adaptation à faire pour faire rentrer un profils_precisions ici ? |
||
NULLIF(TRIM(source.data -> 'offres' ->> 'modes_orientation_beneficiaire'), '') AS "modes_orientation_beneficiaire" | ||
FROM source | ||
LEFT JOIN structures_offres | ||
ON CAST((source.data -> 'offres' ->> 'id_offre') AS INTEGER) = structures_offres.id_offre | ||
) | ||
|
||
SELECT * FROM final |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
SELECT | ||
CAST((data -> 'structures_offres' ->> 'id') AS TEXT) AS "id", | ||
CAST((data -> 'structures_offres' ->> 'offre_id') AS TEXT) AS "id_offre", | ||
CAST((data -> 'structures_offres' ->> 'missionlocale_id') AS TEXT) AS "id_structure" | ||
FROM {{ source('imilo', 'structures_offres') }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mis à part les métadonnées, est-ce qu'il y a des champs qu'on peut considérer obligatoire chez eux ? dans ce cas on peut ajouter des
not_null