-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mes_aides): add permis velos from mes_aides source
- Loading branch information
Showing
26 changed files
with
965 additions
and
229 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
pipeline/dbt/models/intermediate/sources/mes_aides/garage/_mes_aides_garage__models.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: int_mes_aides__garages__adresses | ||
data_tests: | ||
- check_adresse: | ||
config: | ||
severity: warn | ||
columns: | ||
- name: id | ||
data_tests: | ||
- unique | ||
- not_null | ||
- dbt_utils.not_empty_string | ||
|
||
- name: int_mes_aides__garages__structures | ||
data_tests: | ||
- check_structure: | ||
config: | ||
severity: warn | ||
columns: | ||
- name: id | ||
data_tests: | ||
- unique | ||
- not_null | ||
- dbt_utils.not_empty_string | ||
- name: adresse_id | ||
data_tests: | ||
- not_null | ||
- relationships: | ||
to: ref('int_mes_aides__garages__adresses') | ||
field: id | ||
|
||
- name: int_mes_aides__garages__services | ||
data_tests: | ||
- check_service: | ||
config: | ||
severity: warn | ||
columns: | ||
- name: id | ||
data_tests: | ||
- unique | ||
- not_null | ||
- dbt_utils.not_empty_string | ||
- name: structure_id | ||
data_tests: | ||
- not_null | ||
- relationships: | ||
to: ref('int_mes_aides__garages__structures') | ||
field: id | ||
- name: adresse_id | ||
data_tests: | ||
- not_null | ||
- relationships: | ||
to: ref('int_mes_aides__garages__adresses') | ||
field: id |
19 changes: 19 additions & 0 deletions
19
...ine/dbt/models/intermediate/sources/mes_aides/garage/int_mes_aides__garages__adresses.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
WITH garages AS ( | ||
SELECT * FROM {{ ref('stg_mes_aides__garages') }} | ||
), | ||
|
||
final AS ( | ||
SELECT | ||
id AS "id", | ||
ville_nom AS "commune", | ||
code_postal AS "code_postal", | ||
code_insee AS "code_insee", | ||
adresse AS "adresse", | ||
NULL AS "complement_adresse", | ||
longitude AS "longitude", | ||
latitude AS "latitude", | ||
_di_source_id AS "source" | ||
FROM garages | ||
) | ||
|
||
SELECT * FROM final |
103 changes: 103 additions & 0 deletions
103
...ine/dbt/models/intermediate/sources/mes_aides/garage/int_mes_aides__garages__services.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
{% set check_structure_str = "Veuillez vérifier sur le site internet de la structure" %} | ||
|
||
WITH garages AS ( | ||
SELECT * FROM {{ ref('stg_mes_aides__garages') }} | ||
), | ||
|
||
service_types_by_garage AS ( | ||
SELECT | ||
garages.id, | ||
service_type | ||
FROM garages, | ||
UNNEST(garages.services) AS service_type | ||
), | ||
|
||
final AS ( | ||
SELECT | ||
garages.id AS "adresse_id", | ||
TRUE AS "contact_public", | ||
TRUE AS "cumulable", | ||
garages.cree_le AS "date_creation", | ||
garages.modifie_le AS "date_maj", | ||
NULL::DATE AS "date_suspension", | ||
NULL AS "formulaire_en_ligne", | ||
'{{ check_structure_str }}' AS "frais_autres", | ||
(UUID(MD5(garages.id || COALESCE(service_types_by_garage.service_type, ''))))::TEXT AS "id", | ||
NULL::TEXT [] AS "justificatifs", | ||
'https://mes-aides.francetravail.fr/transport-et-mobilite/garages-solidaires' AS "lien_source", | ||
ARRAY['en-presentiel'] AS "modes_accueil", | ||
ARRAY_REMOVE( | ||
ARRAY[ | ||
CASE WHEN garages.telephone IS NOT NULL THEN 'telephoner' END, | ||
CASE WHEN garages.email IS NOT NULL THEN 'envoyer-un-mail' END | ||
], | ||
NULL | ||
) AS "modes_orientation_accompagnateur", | ||
CASE | ||
WHEN | ||
garages.telephone IS NULL | ||
AND garages.email IS NULL | ||
THEN '{{ check_structure_str }}' | ||
END AS "modes_orientation_accompagnateur_autres", | ||
ARRAY_REMOVE( | ||
ARRAY[ | ||
'se-presenter', | ||
CASE WHEN garages.telephone IS NOT NULL THEN 'telephoner' END, | ||
CASE WHEN garages.email IS NOT NULL THEN 'envoyer-un-mail' END | ||
], | ||
NULL | ||
) AS "modes_orientation_beneficiaire", | ||
NULL AS "modes_orientation_beneficiaire_autres", | ||
FORMAT( | ||
'%s de %s', | ||
COALESCE(service_types_by_garage.service_type, 'Réparation, vente et location'), | ||
LOWER(COALESCE(NULLIF(ARRAY_TO_STRING(garages.types_de_vehicule, ', '), ''), 'véhicule')) | ||
) AS "nom", | ||
FORMAT( | ||
'%s de %s à tarif solidaire pour les personnes en difficulté, et selon leur situation', | ||
COALESCE(service_types_by_garage.service_type, 'Réparation, vente et location'), | ||
LOWER(COALESCE(NULLIF(ARRAY_TO_STRING(garages.types_de_vehicule, ', '), ''), 'véhicule')) | ||
) AS "presentation_resume", | ||
NULL AS "presentation_detail", | ||
NULL AS "prise_rdv", | ||
NULL::TEXT [] AS "profils", | ||
NULL AS "recurrence", | ||
garages._di_source_id AS "source", | ||
garages.id AS "structure_id", | ||
ARRAY_REMOVE( | ||
ARRAY[ | ||
CASE service_types_by_garage.service_type | ||
WHEN 'Achat' THEN 'mobilite--acheter-un-vehicule-motorise' | ||
WHEN 'Location' THEN 'mobilite--louer-un-vehicule' | ||
WHEN 'Réparation' THEN 'mobilite--entretenir-reparer-son-vehicule' | ||
ELSE 'mobilite' | ||
END, | ||
CASE | ||
WHEN | ||
service_types_by_garage.service_type = 'Achat' | ||
AND 'Vélo' = ANY(garages.types_de_vehicule) | ||
THEN 'mobilite--acheter-un-velo' | ||
END | ||
], | ||
NULL | ||
) AS "thematiques", | ||
ARRAY['aide-materielle', 'aide-financiere'] AS "types", | ||
CASE LEFT(garages.code_insee, 2) | ||
WHEN '97' THEN LEFT(garages.code_insee, 3) | ||
ELSE LEFT(garages.code_insee, 2) | ||
END AS "zone_diffusion_code", | ||
NULL AS "zone_diffusion_nom", | ||
'departement' AS "zone_diffusion_type", | ||
garages.criteres_eligibilite AS "pre_requis", | ||
NULL AS "contact_nom_prenom", | ||
garages.email AS "courriel", | ||
garages.telephone AS "telephone", | ||
NULL::TEXT [] AS "frais", | ||
NULL AS "page_web" | ||
FROM garages | ||
LEFT JOIN service_types_by_garage ON garages.id = service_types_by_garage.id | ||
WHERE | ||
garages.en_ligne | ||
) | ||
|
||
SELECT * FROM final |
32 changes: 32 additions & 0 deletions
32
...e/dbt/models/intermediate/sources/mes_aides/garage/int_mes_aides__garages__structures.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
WITH garages AS ( | ||
SELECT * FROM {{ ref('stg_mes_aides__garages') }} | ||
), | ||
|
||
final AS ( | ||
SELECT | ||
id AS "id", | ||
id AS "adresse_id", | ||
siret AS "siret", | ||
NULL::BOOLEAN AS "antenne", | ||
NULL AS "rna", | ||
nom AS "nom", | ||
telephone AS "telephone", | ||
email AS "courriel", | ||
url AS "site_web", | ||
_di_source_id AS "source", | ||
NULL AS "lien_source", | ||
NULL AS "horaires_ouverture", | ||
NULL AS "accessibilite", | ||
NULL::TEXT [] AS "labels_nationaux", | ||
NULL::TEXT [] AS "labels_autres", | ||
NULL AS "typologie", | ||
NULL AS "presentation_resume", | ||
NULL AS "presentation_detail", | ||
modifie_le::DATE AS "date_maj", | ||
ARRAY['mobilite'] AS "thematiques" | ||
FROM garages | ||
WHERE | ||
en_ligne | ||
) | ||
|
||
SELECT * FROM final |
22 changes: 3 additions & 19 deletions
22
pipeline/dbt/models/intermediate/sources/mes_aides/int_mes_aides__adresses.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,3 @@ | ||
WITH garages AS ( | ||
SELECT * FROM {{ ref('stg_mes_aides__garages') }} | ||
), | ||
|
||
final AS ( | ||
SELECT | ||
id AS "id", | ||
ville_nom AS "commune", | ||
code_postal AS "code_postal", | ||
code_insee AS "code_insee", | ||
adresse AS "adresse", | ||
NULL AS "complement_adresse", | ||
longitude AS "longitude", | ||
latitude AS "latitude", | ||
_di_source_id AS "source" | ||
FROM garages | ||
) | ||
|
||
SELECT * FROM final | ||
{{ dbt_utils.union_relations( | ||
relations=[ref('int_mes_aides__garages__adresses'), ref('int_mes_aides__permis_velo__adresses')] | ||
) }} |
18 changes: 5 additions & 13 deletions
18
pipeline/dbt/models/intermediate/sources/mes_aides/int_mes_aides__contacts.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.