-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from OpenSourcePolitics/add_private_field_lyon
adding awesome proposal fields models to Lyon
- Loading branch information
Showing
4 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
...ts/lyon/models/intermediate/decidim_awesome/int_decidim_awesome_proposal_extra_fields.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 parsed_data AS ( | ||
SELECT | ||
decidim_awesome_proposal_extra_fields.id, | ||
decidim_awesome_proposal_extra_fields.proposal_id, | ||
xpath('//text()', unnest(xpath('//dt', xml_data)))::text AS private_field_description, | ||
unnest(xpath('//dd/div/text()', unnest(xpath('//dd', xml_data))))::text AS private_field_content | ||
FROM | ||
{{ ref ("stg_decidim_awesome_proposal_extra_fields")}} AS decidim_awesome_proposal_extra_fields, | ||
LATERAL xmlparse(document private_body) AS xml_data | ||
) | ||
SELECT | ||
parsed_data.id, | ||
parsed_data.proposal_id, | ||
replace(replace(private_field_description, '{"', ''), '"}', '') AS private_field_description, | ||
parsed_data.private_field_content | ||
FROM | ||
parsed_data | ||
WHERE | ||
private_field_content IS NOT NULL |
11 changes: 11 additions & 0 deletions
11
...sals/projects/lyon/models/marts/decidim_awesome/decidim_awesome_proposal_extra_fields.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,11 @@ | ||
SELECT | ||
decidim_awesome_proposal_extra_fields.id, | ||
decidim_awesome_proposal_extra_fields.proposal_id, | ||
decidim_awesome_proposal_extra_fields.private_field_description, | ||
decidim_awesome_proposal_extra_fields.private_field_content, | ||
decidim_proposals_proposals.decidim_component_id, | ||
components.ps_title | ||
FROM | ||
{{ ref ("int_decidim_awesome_proposal_extra_fields")}} AS decidim_awesome_proposal_extra_fields | ||
JOIN {{ ref ("stg_decidim_proposals")}} AS decidim_proposals_proposals ON decidim_awesome_proposal_extra_fields.proposal_id = decidim_proposals_proposals.id | ||
JOIN {{ ref ("components")}} AS components ON decidim_proposals_proposals.decidim_component_id = components.id |
12 changes: 12 additions & 0 deletions
12
...ecidim/projects/lyon/models/staging/decidim/stg_decidim_awesome_proposal_extra_fields.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,12 @@ | ||
WITH source AS ( | ||
SELECT * FROM {{ source('decidim', 'decidim_awesome_proposal_extra_fields') }} | ||
) | ||
|
||
|
||
SELECT | ||
id, | ||
decidim_proposal_id AS proposal_id, | ||
updated_at, | ||
created_at, | ||
replace(decrypted_private_body, ' ', '') AS private_body | ||
FROM source |
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,8 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: decidim | ||
database: "{{ env_var('DBNAME') }}" | ||
schema: public | ||
tables: | ||
- name: decidim_awesome_proposal_extra_fields |