Skip to content

Commit

Permalink
feat(dora): basic profils mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
vmttn committed Jun 28, 2023
1 parent c733974 commit 2e00fbf
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions pipeline/dbt/models/intermediate/dora/int_dora__services.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@ WITH services AS (
SELECT * FROM {{ ref('stg_dora__services') }}
),

di_profil_by_dora_profil AS (
-- dora's thematiques are not yet normalized
SELECT x.*
FROM (
VALUES
('Adultes', 'adultes'),
('Femmes', 'femmes')
) AS x (dora_profil, di_profil)
),

final AS (
SELECT
id AS "adresse_id",
Expand All @@ -13,7 +23,6 @@ final AS (
date_suspension::DATE AS "date_suspension",
formulaire_en_ligne AS "formulaire_en_ligne",
frais_autres AS "frais_autres",
ARRAY[frais] AS "frais",
id AS "id",
justificatifs AS "justificatifs",
lien_source AS "lien_source",
Expand All @@ -22,17 +31,22 @@ final AS (
presentation_resume AS "presentation_resume",
presentation_detail AS "presentation_detail",
prise_rdv AS "prise_rdv",
profils AS "profils",
ARRAY(
SELECT di_profil_by_dora_profil.di_profil
FROM di_profil_by_dora_profil
WHERE di_profil_by_dora_profil.dora_profil = ANY(services.profils)
)::TEXT [] AS "profils",
recurrence AS "recurrence",
_di_source_id AS "source",
structure_id AS "structure_id",
NULL AS "telephone", -- ignored for now
thematiques AS "thematiques",
NULL AS "telephone",
thematiques AS "thematiques", -- ignored for now
types AS "types",
zone_diffusion_code AS "zone_diffusion_code",
zone_diffusion_nom AS "zone_diffusion_nom",
zone_diffusion_type AS "zone_diffusion_type",
pre_requis AS "pre_requis"
pre_requis AS "pre_requis",
ARRAY[frais] AS "frais"
FROM services
)

Expand Down

0 comments on commit 2e00fbf

Please sign in to comment.