-
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 #73 from OpenSourcePolitics/custom_states_in_demo
feat(proposals): add macro to be backward compatible for proposal state
- Loading branch information
Showing
18 changed files
with
135 additions
and
219 deletions.
There are no files selected for viewing
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,5 +1,4 @@ | ||
packages: | ||
- local: ../demo | ||
- local: ../packages/decidim_app/proposal_states | ||
- package: dbt-labs/dbt_utils | ||
version: 1.2.0 |
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 @@ | ||
{% macro get_column_if_exists(relation, column_name, cast_type="TEXT", default_value="NULL") %} | ||
{% set columns = adapter.get_columns_in_relation(relation) %} | ||
{% if column_name in columns | map(attribute="name") %} | ||
{{ column_name }} | ||
{% else %} | ||
{% if cast_type %} | ||
CAST({{ default_value }} AS {{ cast_type }}) AS {{ column_name }} | ||
{% endif %} | ||
{% endif %} | ||
{% endmacro %} | ||
|
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
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
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
27 changes: 27 additions & 0 deletions
27
projects/demo/models/staging/decidim/proposals/stg_decidim_proposals_custom_states.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,27 @@ | ||
{% set lang = var('DBT_LANG', 'fr') %} | ||
|
||
{% set relation = adapter.get_relation( | ||
database=target.database, | ||
schema='public', | ||
identifier='decidim_proposals_proposal_states' | ||
) %} | ||
|
||
{% if relation is not none %} | ||
SELECT | ||
id, | ||
token, | ||
title::jsonb->>'{{ lang }}' AS title, | ||
description, | ||
decidim_component_id, | ||
proposals_count | ||
FROM {{ source('decidim', 'decidim_proposals_proposal_states') }} | ||
{% else %} | ||
SELECT | ||
CAST(NULL AS INTEGER) AS id, | ||
CAST(NULL AS TEXT) AS token, | ||
CAST(NULL AS TEXT) AS title, | ||
CAST(NULL AS TEXT) AS description, | ||
CAST(NULL AS INTEGER) AS decidim_component_id, | ||
CAST(NULL AS INTEGER) AS proposals_count | ||
LIMIT 0 | ||
{% endif %} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
packages: | ||
- local: ../demo | ||
- local: ../packages/decidim_app/proposal_states | ||
- local: ../packages/decidim_awesome/proposal_extra_fields | ||
- package: dbt-labs/dbt_utils | ||
version: 1.2.0 |
34 changes: 0 additions & 34 deletions
34
projects/packages/decidim_app/proposal_states/dbt_project.yml
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
...cts/packages/decidim_app/proposal_states/models/intermediate/int_proposals_with_state.sql
This file was deleted.
Oops, something went wrong.
70 changes: 0 additions & 70 deletions
70
projects/packages/decidim_app/proposal_states/models/marts/proposals_with_state.sql
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.