diff --git a/pipeline/dbt/models/intermediate/sources/france_travail/_france_travail_models.yml b/pipeline/dbt/models/intermediate/sources/france_travail/_france_travail_models.yml index a5c2fabc..b0b80197 100644 --- a/pipeline/dbt/models/intermediate/sources/france_travail/_france_travail_models.yml +++ b/pipeline/dbt/models/intermediate/sources/france_travail/_france_travail_models.yml @@ -36,6 +36,11 @@ models: - relationships: to: ref('int_france_travail__adresses') field: id + - name: zone_diffusion_code + data_tests: + - not_null: + config: + where: "nom IN ('Bilan/Accompagnement mobilité') AND zone_diffusion_code LIKE '69%'" - name: int_france_travail__structures data_tests: diff --git a/pipeline/dbt/models/intermediate/sources/france_travail/int_france_travail__services.sql b/pipeline/dbt/models/intermediate/sources/france_travail/int_france_travail__services.sql index dc9ea2e7..6697e7db 100644 --- a/pipeline/dbt/models/intermediate/sources/france_travail/int_france_travail__services.sql +++ b/pipeline/dbt/models/intermediate/sources/france_travail/int_france_travail__services.sql @@ -19,6 +19,15 @@ structures_with_commune AS ( LEFT JOIN adresses ON agences.id = adresses.id ), +excluded_ids AS ( + SELECT structures.id || '-' || services.id AS id + FROM services + CROSS JOIN structures_with_commune AS structures + WHERE + services.nom = 'Bilan/Accompagnement mobilité' + AND structures.code_insee LIKE '69%' +), + final AS ( SELECT services._di_source_id AS "source", @@ -54,10 +63,12 @@ final AS ( structures.code_insee AS "zone_diffusion_code", structures.commune AS "zone_diffusion_nom", NULL AS "page_web", - CAST(NULL AS DATE) AS "date_suspension", + NULL::DATE AS "date_suspension", structures.id || '-' || services.id AS "id" FROM services CROSS JOIN structures_with_commune AS structures + WHERE + structures.id || '-' || services.id NOT IN (SELECT excluded_ids.id FROM excluded_ids) ) SELECT * FROM final