Skip to content

Commit

Permalink
fix(fredo): select first email from list
Browse files Browse the repository at this point in the history
  • Loading branch information
hlecuyer authored and vmttn committed Sep 17, 2024
1 parent 3367584 commit 641cbc5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ final AS (
CASE
WHEN ARRAY_LENGTH(structures.telephone, 1) > 0 THEN structures.telephone[1]
END AS "telephone",
structures.courriel AS "courriel",
CASE
WHEN ARRAY_LENGTH(structures.courriel, 1) > 0 THEN structures.courriel[1]
END AS "courriel",
structures.site_web AS "site_web",
LEFT(structures.presentation_resume, 280) AS "presentation_resume",
structures.presentation_resume AS "presentation_detail",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ final AS (
_di_source_id AS "_di_source_id",
data ->> 'id' AS "id",
NULLIF(TRIM(data ->> 'adresse'), '') AS "adresse",
NULLIF(TRIM(data ->> 'email'), '') AS "courriel",
NULLIF(TRIM(data ->> 'code_postal'), '') AS "code_postal",
NULLIF(TRIM(data ->> 'commune'), '') AS "commune",
NULLIF(TRIM(data ->> 'frais'), '') AS "frais",
Expand All @@ -24,6 +23,11 @@ final AS (
THEN CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(data -> 'telephone')) AS TEXT [])
ELSE CAST(NULL AS TEXT [])
END AS "telephone",
CASE
WHEN data ->> 'email' IS NOT NULL
THEN CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(data -> 'email')) AS TEXT [])
ELSE CAST(NULL AS TEXT [])
END AS "courriel",
CASE
WHEN data ->> 'categories' IS NOT NULL
THEN CAST(ARRAY(SELECT * FROM JSONB_ARRAY_ELEMENTS_TEXT(data -> 'categories')) AS TEXT [])
Expand Down

0 comments on commit 641cbc5

Please sign in to comment.