-
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 #74 from OpenSourcePolitics/0.29_new_columns
feat(demo): anticipate new columns for 0.29 migration
- Loading branch information
Showing
6 changed files
with
82 additions
and
104 deletions.
There are no files selected for viewing
26 changes: 10 additions & 16 deletions
26
projects/demo/models/staging/decidim/blogs_posts/stg_decidim_blogs_posts.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 |
---|---|---|
@@ -1,18 +1,12 @@ | ||
{% set lang = var('DBT_LANG', 'fr') %} | ||
|
||
WITH source AS ( | ||
SELECT * FROM {{ source('decidim', 'decidim_blogs_posts') }} | ||
), | ||
renamed AS ( | ||
SELECT | ||
id, | ||
title::jsonb->>'{{ lang }}' AS title, | ||
regexp_replace(body::jsonb->>'{{ lang }}', E'(<[^>]+>)|(&[a-z]+;)', '', 'gi') AS body, | ||
decidim_component_id, | ||
created_at, | ||
decidim_author_id, | ||
'Decidim::Blogs::Post' AS resource_type | ||
FROM source | ||
) | ||
SELECT * FROM renamed | ||
|
||
SELECT | ||
id, | ||
title::jsonb->>'{{ lang }}' AS title, | ||
regexp_replace(body::jsonb->>'{{ lang }}', E'(<[^>]+>)|(&[a-z]+;)', '', 'gi') AS body, | ||
decidim_component_id, | ||
created_at, | ||
decidim_author_id, | ||
{{ get_column_if_exists(source('decidim', 'decidim_blogs_posts'), 'published_at', 'TIMESTAMP') }}, | ||
'Decidim::Blogs::Post' AS resource_type | ||
FROM {{ source('decidim', 'decidim_blogs_posts') }} |
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
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
36 changes: 15 additions & 21 deletions
36
projects/demo/models/staging/decidim/stg_decidim_attachments.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 |
---|---|---|
@@ -1,21 +1,15 @@ | ||
WITH source AS ( | ||
SELECT * FROM {{ source('decidim', 'decidim_attachments') }} | ||
), | ||
renamed as ( | ||
SELECT | ||
id, | ||
title, | ||
description, | ||
file, | ||
content_type, | ||
file_size, | ||
attached_to_id, | ||
created_at, | ||
updated_at, | ||
attached_to_type, | ||
weight, | ||
attachment_collection_id | ||
FROM source | ||
) | ||
SELECT * FROM renamed | ||
|
||
SELECT | ||
id, | ||
title, | ||
description, | ||
file, | ||
content_type, | ||
file_size, | ||
attached_to_id, | ||
created_at, | ||
updated_at, | ||
attached_to_type, | ||
weight, | ||
attachment_collection_id, | ||
{{ get_column_if_exists(source('decidim', 'decidim_attachments'), 'link', 'TEXT') }} | ||
FROM {{ source('decidim', 'decidim_attachments') }} |
40 changes: 18 additions & 22 deletions
40
projects/demo/models/staging/decidim/stg_decidim_comments.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 |
---|---|---|
@@ -1,25 +1,21 @@ | ||
{% set lang = var('DBT_LANG', 'fr') %} | ||
|
||
WITH source AS ( | ||
SELECT * FROM {{ source('decidim', 'decidim_comments_comments') }} | ||
), | ||
renamed as ( | ||
SELECT | ||
id, | ||
decidim_commentable_type, | ||
decidim_commentable_id, | ||
decidim_author_id, | ||
created_at, | ||
updated_at, | ||
depth, | ||
alignment, | ||
decidim_user_group_id, | ||
decidim_root_commentable_type, | ||
decidim_root_commentable_id, | ||
decidim_author_type, | ||
body::jsonb->>'{{ lang }}' as body, | ||
comments_count | ||
FROM source | ||
) | ||
SELECT * FROM renamed | ||
SELECT | ||
id, | ||
decidim_commentable_type, | ||
decidim_commentable_id, | ||
decidim_author_id, | ||
created_at, | ||
updated_at, | ||
depth, | ||
alignment, | ||
decidim_user_group_id, | ||
decidim_root_commentable_type, | ||
decidim_root_commentable_id, | ||
decidim_author_type, | ||
body::jsonb->>'{{ lang }}' as body, | ||
comments_count, | ||
{{ get_column_if_exists(source('decidim', 'decidim_comments_comments'), 'up_votes_count', 'INTEGER') }}, | ||
{{ get_column_if_exists(source('decidim', 'decidim_comments_comments'), 'down_votes_count', 'INTEGER') }} | ||
FROM {{ source('decidim', 'decidim_comments_comments') }} | ||
|
41 changes: 18 additions & 23 deletions
41
projects/demo/models/staging/decidim/stg_decidim_meetings.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 |
---|---|---|
@@ -1,25 +1,20 @@ | ||
{% set lang = var('DBT_LANG', 'fr') %} | ||
|
||
WITH source AS ( | ||
SELECT * FROM {{ source('decidim', 'decidim_meetings_meetings') }} | ||
), | ||
renamed AS ( | ||
SELECT | ||
id, | ||
title::jsonb->>'{{ lang }}' AS title, | ||
regexp_replace(description::jsonb->>'{{ lang }}', E'(<[^>]+>)|(&[a-z]+;)', '', 'gi') AS description, | ||
coalesce(nullif(address,''), 'Pas d''adresse') as address, | ||
coalesce(attendees_count, 0) as attendees_count, | ||
created_at, | ||
decidim_scope_id, | ||
decidim_component_id, | ||
start_time, | ||
end_time, | ||
registration_url, | ||
type_of_meeting, | ||
private_meeting, | ||
decidim_author_id, | ||
'Decidim::Meetings::Meeting' as resource_type | ||
FROM source | ||
) | ||
SELECT * FROM renamed | ||
SELECT | ||
id, | ||
title::jsonb->>'{{ lang }}' AS title, | ||
regexp_replace(description::jsonb->>'{{ lang }}', E'(<[^>]+>)|(&[a-z]+;)', '', 'gi') AS description, | ||
coalesce(nullif(address,''), 'Pas d''adresse') as address, | ||
coalesce(attendees_count, 0) as attendees_count, | ||
created_at, | ||
{{ get_column_if_exists(source('decidim', 'decidim_proposals_proposals'), 'withdrawn_at', 'TIMESTAMP') }}, | ||
decidim_scope_id, | ||
decidim_component_id, | ||
start_time, | ||
end_time, | ||
registration_url, | ||
type_of_meeting, | ||
private_meeting, | ||
decidim_author_id, | ||
'Decidim::Meetings::Meeting' as resource_type | ||
FROM {{ source('decidim', 'decidim_meetings_meetings') }} |