diff --git a/pipeline/dbt/models/intermediate/sources/cd35/int_cd35__structures.sql b/pipeline/dbt/models/intermediate/sources/cd35/int_cd35__structures.sql index 39d6ee0f..2860a4f5 100644 --- a/pipeline/dbt/models/intermediate/sources/cd35/int_cd35__structures.sql +++ b/pipeline/dbt/models/intermediate/sources/cd35/int_cd35__structures.sql @@ -25,13 +25,13 @@ final AS ( WHEN 'CCAS' THEN 'CCAS' WHEN 'MAIRIE' THEN 'MUNI' END AS "typologie", - CASE LENGTH(presentation_detail) <= 280 - WHEN TRUE THEN presentation_detail - WHEN FALSE THEN LEFT(presentation_detail, 279) || '…' + CASE + WHEN LENGTH(presentation_detail) <= 280 THEN presentation_detail + ELSE LEFT(presentation_detail, 279) || '…' END AS "presentation_resume", - CASE LENGTH(presentation_detail) <= 280 - WHEN TRUE THEN NULL - WHEN FALSE THEN presentation_detail + CASE + WHEN LENGTH(presentation_detail) <= 280 THEN NULL + ELSE presentation_detail END AS "presentation_detail" FROM organisations ) diff --git a/pipeline/dbt/models/intermediate/sources/monenfant/int_monenfant__structures.sql b/pipeline/dbt/models/intermediate/sources/monenfant/int_monenfant__structures.sql index 4d229e2c..df960fcb 100644 --- a/pipeline/dbt/models/intermediate/sources/monenfant/int_monenfant__structures.sql +++ b/pipeline/dbt/models/intermediate/sources/monenfant/int_monenfant__structures.sql @@ -4,26 +4,26 @@ WITH creches AS ( final AS ( SELECT - id AS "id", - id AS "adresse_id", - NULL AS "siret", - NULL::BOOLEAN AS "antenne", - NULL AS "rna", - nom AS "nom", - telephone AS "telephone", - mail AS "courriel", - details__website AS "site_web", - _di_source_id AS "source", - 'https://monenfant.fr/que-recherchez-vous/' || result_id AS "lien_source", - details__infos_pratiques__jour_horaire AS "horaires_ouverture", - NULL AS "accessibilite", - NULL::TEXT [] AS "labels_nationaux", - NULL::TEXT [] AS "labels_autres", - CASE WHEN avip THEN 'AVIP' END AS "typologie", + id AS "id", + id AS "adresse_id", + NULL AS "siret", + NULL::BOOLEAN AS "antenne", + NULL AS "rna", + nom AS "nom", + telephone AS "telephone", + mail AS "courriel", + details__website AS "site_web", + _di_source_id AS "source", + 'https://monenfant.fr/que-recherchez-vous/' || result_id AS "lien_source", + details__infos_pratiques__jour_horaire AS "horaires_ouverture", + NULL AS "accessibilite", + NULL::TEXT [] AS "labels_nationaux", + NULL::TEXT [] AS "labels_autres", + CASE WHEN avip THEN 'AVIP' END AS "typologie", {{ truncate_text("details__presentation__structure_projet") }} AS "presentation_resume", - details__presentation__structure_projet AS "presentation_detail", - derniere_modif_date AS "date_maj", - ARRAY['famille--garde-denfants'] AS "thematiques" + details__presentation__structure_projet AS "presentation_detail", + derniere_modif_date AS "date_maj", + ARRAY['famille--garde-denfants'] AS "thematiques" FROM creches ) diff --git a/pipeline/dbt/models/intermediate/sources/odspep/int_odspep__services.sql b/pipeline/dbt/models/intermediate/sources/odspep/int_odspep__services.sql index c992235d..eed98ae4 100644 --- a/pipeline/dbt/models/intermediate/sources/odspep/int_odspep__services.sql +++ b/pipeline/dbt/models/intermediate/sources/odspep/int_odspep__services.sql @@ -53,13 +53,13 @@ final AS ( WHERE ressources_partenariales.type_res_part = di_thematique_by_odspep_type_res_part.type_res_part )::TEXT [] AS "thematiques", CONCAT(id_res, '_', zone_diffusion_unique_code) AS "id", - CASE LENGTH(service_description) <= 280 - WHEN TRUE THEN service_description - WHEN FALSE THEN LEFT(service_description, 279) || '…' + CASE + WHEN LENGTH(service_description) <= 280 THEN service_description + ELSE LEFT(service_description, 279) || '…' END AS "presentation_resume", - CASE LENGTH(service_description) <= 280 - WHEN TRUE THEN NULL - WHEN FALSE THEN service_description + CASE + WHEN LENGTH(service_description) <= 280 THEN NULL + ELSE service_description END AS "presentation_detail" FROM ressources_partenariales ORDER BY 1 diff --git a/pipeline/dbt/models/intermediate/sources/soliguide/int_soliguide__services.sql b/pipeline/dbt/models/intermediate/sources/soliguide/int_soliguide__services.sql index 5e57f6a7..4a6de0ac 100644 --- a/pipeline/dbt/models/intermediate/sources/soliguide/int_soliguide__services.sql +++ b/pipeline/dbt/models/intermediate/sources/soliguide/int_soliguide__services.sql @@ -47,7 +47,7 @@ di_thematique_by_soliguide_category_code AS ( ('mobility', ARRAY['mobilite']), ('other_activities', ARRAY['remobilisation--decouvrir-son-potentiel-via-le-sport-et-la-culture']), ('overnight_stop', ARRAY['logement-hebergement--mal-loges-sans-logis']), - ('parent_assistance', ARRAY['famille--information-et-accompagnement-des-parents','famille--soutien-a-la-parentalite', 'famille--soutien-aux-familles']), + ('parent_assistance', ARRAY['famille--information-et-accompagnement-des-parents', 'famille--soutien-a-la-parentalite', 'famille--soutien-aux-familles']), ('provision_of_vehicles', ARRAY['mobilite--louer-un-vehicule']), ('psychological_support', ARRAY['sante--bien-etre-psychologique']), ('public_writer', ARRAY['acces-aux-droits-et-citoyennete--accompagnement-dans-les-demarches-administratives', 'numerique--realiser-des-demarches-administratives-avec-un-accompagnement']), @@ -89,7 +89,7 @@ open_services AS ( CURRENT_DATE AT TIME ZONE 'Europe/Paris', CURRENT_DATE AT TIME ZONE 'Europe/Paris' ) - OVERLAPS + OVERLAPS -- noqa: LT02 ( COALESCE(close__date_debut, CURRENT_DATE - INTERVAL '1 year'), COALESCE(close__date_fin, CURRENT_DATE + INTERVAL '1 year') @@ -132,13 +132,13 @@ final AS ( ARRAY['en-presentiel'] AS "modes_accueil", categories.label || COALESCE(' : ' || open_services.name, '') AS "nom", 'https://soliguide.fr/fr/fiche/' || lieux.seo_url AS "lien_source", - CASE LENGTH(open_services.description) <= 280 - WHEN TRUE THEN open_services.description - WHEN FALSE THEN LEFT(open_services.description, 279) || '…' + CASE + WHEN LENGTH(open_services.description) <= 280 THEN open_services.description + ELSE LEFT(open_services.description, 279) || '…' END AS "presentation_resume", - CASE LENGTH(open_services.description) <= 280 - WHEN TRUE THEN NULL - WHEN FALSE THEN open_services.description + CASE + WHEN LENGTH(open_services.description) <= 280 THEN NULL + ELSE open_services.description END AS "presentation_detail", CASE WHEN open_services.different_hours diff --git a/pipeline/dbt/models/intermediate/sources/soliguide/int_soliguide__structures.sql b/pipeline/dbt/models/intermediate/sources/soliguide/int_soliguide__structures.sql index f48e6123..3635ba7e 100644 --- a/pipeline/dbt/models/intermediate/sources/soliguide/int_soliguide__structures.sql +++ b/pipeline/dbt/models/intermediate/sources/soliguide/int_soliguide__structures.sql @@ -28,13 +28,13 @@ final AS ( NULL AS "telephone", 'https://soliguide.fr/fr/fiche/' || lieux.seo_url AS "lien_source", UDF_SOLIGUIDE__NEW_HOURS_TO_OSM_OPENING_HOURS(lieux.newhours) AS "horaires_ouverture", - CASE LENGTH(lieux.description) <= 280 - WHEN TRUE THEN lieux.description - WHEN FALSE THEN LEFT(lieux.description, 279) || '…' + CASE + WHEN LENGTH(lieux.description) <= 280 THEN lieux.description + ELSE LEFT(lieux.description, 279) || '…' END AS "presentation_resume", - CASE LENGTH(lieux.description) <= 280 - WHEN TRUE THEN NULL - WHEN FALSE THEN lieux.description + CASE + WHEN LENGTH(lieux.description) <= 280 THEN NULL + ELSE lieux.description END AS "presentation_detail" FROM lieux ORDER BY 1 diff --git a/pipeline/dbt/models/staging/brevo/stg_brevo__contacts.sql b/pipeline/dbt/models/staging/brevo/stg_brevo__contacts.sql index a4b65bb4..e72cfd1f 100644 --- a/pipeline/dbt/models/staging/brevo/stg_brevo__contacts.sql +++ b/pipeline/dbt/models/staging/brevo/stg_brevo__contacts.sql @@ -4,15 +4,15 @@ WITH source AS ( final AS ( SELECT - (data ->> 'emailBlacklisted')::BOOLEAN AS "email_blacklisted", - (data ->> 'smsBlacklisted')::BOOLEAN AS "sms_blacklisted", - (data ->> 'createdAt')::TIMESTAMP WITH TIME ZONE AS "created_at", - (data ->> 'modifiedAt')::TIMESTAMP WITH TIME ZONE AS "modified_at", - ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS(data -> 'listIds'))::INT [] AS "list_ids", - data ->> 'id' AS "id", - TO_DATE(data -> 'attributes' ->> 'DATE_DI_RGPD_OPPOSITION', 'YYYY-MM-DD') AS "date_di_rgpd_opposition", - data -> 'attributes' ->> 'CONTACT_UIDS' AS "contact_uids", - NULLIF(TRIM(data ->> 'email'), '') AS "email" + CAST((data ->> 'emailBlacklisted') AS BOOLEAN) AS "email_blacklisted", + CAST((data ->> 'smsBlacklisted') AS BOOLEAN) AS "sms_blacklisted", + CAST((data ->> 'createdAt') AS TIMESTAMP WITH TIME ZONE) AS "created_at", + CAST((data ->> 'modifiedAt') AS TIMESTAMP WITH TIME ZONE) AS "modified_at", + CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS(data -> 'listIds')) AS INT []) AS "list_ids", + data ->> 'id' AS "id", + TO_DATE(data -> 'attributes' ->> 'DATE_DI_RGPD_OPPOSITION', 'YYYY-MM-DD') AS "date_di_rgpd_opposition", + data -> 'attributes' ->> 'CONTACT_UIDS' AS "contact_uids", + NULLIF(TRIM(data ->> 'email'), '') AS "email" FROM source ) diff --git a/pipeline/dbt/models/staging/sources/soliguide/stg_soliguide__categories.sql b/pipeline/dbt/models/staging/sources/soliguide/stg_soliguide__categories.sql index 561de801..ddbc5c3b 100644 --- a/pipeline/dbt/models/staging/sources/soliguide/stg_soliguide__categories.sql +++ b/pipeline/dbt/models/staging/sources/soliguide/stg_soliguide__categories.sql @@ -3,109 +3,112 @@ -- noqa: disable=JJ01 -SELECT x.* FROM +SELECT + x.code AS "code", + x.label AS "label" +FROM JSONB_EACH_TEXT(CAST($$ -{ - "access_to_housing": "Conseil logement", - "accomodation_and_housing": "Hébergement et logement", - "activities": "Activités", - "acupuncture": "Acupuncture", - "addiction": "Addiction", - "administrative_assistance": "Conseil administratif", - "allergology": "Allergologie", - "animal_assitance": "Animaux", - "baby_parcel": "Colis bébé", - "babysitting": "Garde d'enfants", - "budget_advice": "Conseil budget", - "cardiology": "Cardiologie", - "carpooling": "Co-voiturage", - "chauffeur_driven_transport": "Transport avec chauffeur", - "child_care": "Soins enfants", - "citizen_housing": "Hébergement citoyen", - "clothing": "Vêtements", - "community_garden": "Jardin solidaire", - "computers_at_your_disposal": "Ordinateur", - "cooking_workshop": "Atelier cuisine", - "counseling": "Conseil", - "day_hosting": "Accueil de jour", - "dental_care": "Dentaire", - "dermatology": "Dermatologie", - "digital_safe": "Coffre-fort numérique", - "digital_tools_training": "Atelier numérique", - "disability_advice": "Conseil handicap", - "domiciliation": "Domiciliation", - "echography": "Échographie", - "electrical_outlets_available": "Prise", - "emergency_accommodation": "Hébergement d'urgence", - "endocrinology": "Endocrinologie", - "equipment": "Matériel", - "face_masks": "Masques", - "family_area": "Espace famille", - "food_distribution": "Distribution de repas", - "food_packages": "Panier alimentaire", - "food_voucher": "Bon / chèque alimentaire", - "food": "Alimentation", - "fountain": "Fontaine à eau", - "french_course": "Cours de français", - "gastroenterology": "Gastro-entérologie", - "general_practitioner": "Médecin généraliste", - "gynecology": "Gynécologie", - "health_specialists": "Spécialistes", - "health": "Santé", - "hygiene_and_wellness": "Hygiène et bien-être", - "hygiene_products": "Produits d'hygiène", - "infirmary": "Infirmerie", - "information_point": "Point d'information et d'orientation", - "integration_through_economic_activity": "Insertion par l'activité économique", - "job_coaching": "Accompagnement à l'emploi", - "kinesitherapy": "Kinésithérapie", - "laundry": "Laverie", - "legal_advice": "Permanence juridique", - "libraries": "Bibliothèque", - "long_term_accomodation": "Hébergement à long terme", - "luggage_storage": "Bagagerie", - "mammography": "Mammographie", - "mobility_assistance": "Aide à la mobilité", - "mobility": "Transport / Mobilité", - "museums": "Musée", - "nutrition": "Nutrition", - "ophthalmology": "Ophtalmologie", - "osteopathy": "Ostéopathe", - "other_activities": "Activités diverses", - "otorhinolaryngology": "Oto-rhino-laryngologie", - "overnight_stop": "Halte de nuit", - "parent_assistance": "Conseil aux parents", - "pedicure": "Pédicure", - "phlebology": "Phlébologie", - "pneumology": "Pneumologie", - "pregnancy_care": "Suivi grossesse", - "provision_of_vehicles": "Mise à disposition de véhicule", - "psychological_support": "Psychologie", - "public_writer": "Écrivain public", - "radiology": "Radiologie", - "rest_area": "Espace de repos", - "rheumatology": "Rhumatologie", - "seated_catering": "Restauration assise", - "shared_kitchen": "Cuisine partagée", - "shower": "Douche", - "social_accompaniment": "Accompagnement social", - "social_grocery_stores": "Épicerie Sociale et Solidaire", - "solidarity_fridge": "Frigo solidaire", - "solidarity_store": "Boutique solidaire", - "speech_therapy": "Orthophonie", - "sport_activities": "Activités sportives", - "std_testing": "Dépistage", - "stomatology": "Stomatologie", - "technology": "Technologie", - "telephone_at_your_disposal": "Téléphone", - "toilets": "Toilettes", - "training_and_jobs": "Formation et emploi", - "tutoring": "Soutien scolaire", - "urology": "Urologie", - "vaccination": "Vaccination", - "vet_care": "Vétérinaire", - "welcome": "Accueil", - "wellness": "Bien-être", - "wifi": "Wifi" -} + { + "access_to_housing": "Conseil logement", + "accomodation_and_housing": "Hébergement et logement", + "activities": "Activités", + "acupuncture": "Acupuncture", + "addiction": "Addiction", + "administrative_assistance": "Conseil administratif", + "allergology": "Allergologie", + "animal_assitance": "Animaux", + "baby_parcel": "Colis bébé", + "babysitting": "Garde d'enfants", + "budget_advice": "Conseil budget", + "cardiology": "Cardiologie", + "carpooling": "Co-voiturage", + "chauffeur_driven_transport": "Transport avec chauffeur", + "child_care": "Soins enfants", + "citizen_housing": "Hébergement citoyen", + "clothing": "Vêtements", + "community_garden": "Jardin solidaire", + "computers_at_your_disposal": "Ordinateur", + "cooking_workshop": "Atelier cuisine", + "counseling": "Conseil", + "day_hosting": "Accueil de jour", + "dental_care": "Dentaire", + "dermatology": "Dermatologie", + "digital_safe": "Coffre-fort numérique", + "digital_tools_training": "Atelier numérique", + "disability_advice": "Conseil handicap", + "domiciliation": "Domiciliation", + "echography": "Échographie", + "electrical_outlets_available": "Prise", + "emergency_accommodation": "Hébergement d'urgence", + "endocrinology": "Endocrinologie", + "equipment": "Matériel", + "face_masks": "Masques", + "family_area": "Espace famille", + "food_distribution": "Distribution de repas", + "food_packages": "Panier alimentaire", + "food_voucher": "Bon / chèque alimentaire", + "food": "Alimentation", + "fountain": "Fontaine à eau", + "french_course": "Cours de français", + "gastroenterology": "Gastro-entérologie", + "general_practitioner": "Médecin généraliste", + "gynecology": "Gynécologie", + "health_specialists": "Spécialistes", + "health": "Santé", + "hygiene_and_wellness": "Hygiène et bien-être", + "hygiene_products": "Produits d'hygiène", + "infirmary": "Infirmerie", + "information_point": "Point d'information et d'orientation", + "integration_through_economic_activity": "Insertion par l'activité économique", + "job_coaching": "Accompagnement à l'emploi", + "kinesitherapy": "Kinésithérapie", + "laundry": "Laverie", + "legal_advice": "Permanence juridique", + "libraries": "Bibliothèque", + "long_term_accomodation": "Hébergement à long terme", + "luggage_storage": "Bagagerie", + "mammography": "Mammographie", + "mobility_assistance": "Aide à la mobilité", + "mobility": "Transport / Mobilité", + "museums": "Musée", + "nutrition": "Nutrition", + "ophthalmology": "Ophtalmologie", + "osteopathy": "Ostéopathe", + "other_activities": "Activités diverses", + "otorhinolaryngology": "Oto-rhino-laryngologie", + "overnight_stop": "Halte de nuit", + "parent_assistance": "Conseil aux parents", + "pedicure": "Pédicure", + "phlebology": "Phlébologie", + "pneumology": "Pneumologie", + "pregnancy_care": "Suivi grossesse", + "provision_of_vehicles": "Mise à disposition de véhicule", + "psychological_support": "Psychologie", + "public_writer": "Écrivain public", + "radiology": "Radiologie", + "rest_area": "Espace de repos", + "rheumatology": "Rhumatologie", + "seated_catering": "Restauration assise", + "shared_kitchen": "Cuisine partagée", + "shower": "Douche", + "social_accompaniment": "Accompagnement social", + "social_grocery_stores": "Épicerie Sociale et Solidaire", + "solidarity_fridge": "Frigo solidaire", + "solidarity_store": "Boutique solidaire", + "speech_therapy": "Orthophonie", + "sport_activities": "Activités sportives", + "std_testing": "Dépistage", + "stomatology": "Stomatologie", + "technology": "Technologie", + "telephone_at_your_disposal": "Téléphone", + "toilets": "Toilettes", + "training_and_jobs": "Formation et emploi", + "tutoring": "Soutien scolaire", + "urology": "Urologie", + "vaccination": "Vaccination", + "vet_care": "Vétérinaire", + "welcome": "Accueil", + "wellness": "Bien-être", + "wifi": "Wifi" + } $$ AS JSONB)) AS x (code, label) diff --git a/pipeline/pyproject.toml b/pipeline/pyproject.toml index adccd54d..4105cb44 100644 --- a/pipeline/pyproject.toml +++ b/pipeline/pyproject.toml @@ -34,7 +34,6 @@ markers = ''' [tool.sqlfluff.core] dialect = "postgres" -ignore = "templating" exclude_rules = "layout.long_lines" templater = "dbt"