Skip to content

Commit

Permalink
Merge pull request #71 from OpenSourcePolitics/add_initiatives_to_all…
Browse files Browse the repository at this point in the history
…_projects

feat(initiatives): add initiatives in demo
  • Loading branch information
JeanLouisLamezec authored Feb 11, 2025
2 parents 4027b01 + c17a41e commit 86b65a4
Show file tree
Hide file tree
Showing 18 changed files with 127 additions and 151 deletions.
1 change: 0 additions & 1 deletion projects/cea/packages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
packages:
- local: ../demo
- local: ../packages/initiatives
- package: dbt-labs/dbt_utils
version: 1.2.0
1 change: 0 additions & 1 deletion projects/cese/packages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
packages:
- local: ../demo
- local: ../packages/initiatives
- package: dbt-labs/dbt_utils
version: 1.2.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
hash_id,
decidim_scope_id,
decidim_initiatives.url AS initiative_url
FROM decidim_initiatives_votes
JOIN {{ ref("initiatives")}} AS decidim_initiatives on decidim_initiatives.id = decidim_initiative_id
FROM {{ ref("stg_decidim_initiatives_votes")}} AS decidim_initiatives_votes
JOIN {{ ref("initiatives")}} AS decidim_initiatives on decidim_initiatives.id = decidim_initiative_id
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{% set relation = adapter.get_relation(
database=target.database,
schema='public',
identifier='decidim_initiatives'
) %}

{% if relation is not none %}
SELECT
id,
title,
description,
decidim_organization_id,
decidim_author_id,
published_at,
state,
signature_type,
signature_start_date,
signature_end_date,
answer,
answered_at,
answer_url,
created_at,
updated_at,
decidim_user_group_id,
hashtag,
scoped_type_id,
first_progress_notification_at,
second_progress_notification_at,
decidim_author_type,
reference,
online_votes,
offline_votes,
decidim_area_id,
comments_count,
follows_count
FROM {{ source('decidim', 'decidim_initiatives') }}
{% else %}
SELECT
CAST(NULL AS INTEGER) AS id,
CAST(NULL AS TEXT) AS title,
CAST(NULL AS TEXT) AS description,
CAST(NULL AS INTEGER) AS decidim_organization_id,
CAST(NULL AS INTEGER) AS decidim_author_id,
CAST(NULL AS TIMESTAMP) AS published_at,
CAST(NULL AS INTEGER) AS state,
CAST(NULL AS TEXT) AS signature_type,
CAST(NULL AS TIMESTAMP) AS signature_start_date,
CAST(NULL AS TIMESTAMP) AS signature_end_date,
CAST(NULL AS TEXT) AS answer,
CAST(NULL AS TIMESTAMP) AS answered_at,
CAST(NULL AS TEXT) AS answer_url,
CAST(NULL AS TIMESTAMP) AS created_at,
CAST(NULL AS TIMESTAMP) AS updated_at,
CAST(NULL AS INTEGER) AS decidim_user_group_id,
CAST(NULL AS TEXT) AS hashtag,
CAST(NULL AS INTEGER) AS scoped_type_id,
CAST(NULL AS TIMESTAMP) AS first_progress_notification_at,
CAST(NULL AS TIMESTAMP) AS second_progress_notification_at,
CAST(NULL AS TEXT) AS decidim_author_type,
CAST(NULL AS TEXT) AS reference,
CAST(NULL AS TEXT) AS online_votes,
CAST(NULL AS TEXT) AS offline_votes,
CAST(NULL AS INTEGER) AS decidim_area_id,
CAST(NULL AS INTEGER) AS comments_count,
CAST(NULL AS INTEGER) AS follows_count
LIMIT 0
{% endif %}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{% set relation = adapter.get_relation(
database=target.database,
schema='public',
identifier='decidim_initiatives_type_scopes'
) %}

{% if relation is not none %}
SELECT
id,
decidim_initiatives_types_id,
decidim_scopes_id,
supports_required,
created_at,
updated_at
FROM {{ source('decidim', 'decidim_initiatives_type_scopes') }}
{% else %}
SELECT
CAST(NULL AS INTEGER) AS id,
CAST(NULL AS INTEGER) AS decidim_initiatives_types_id,
CAST(NULL AS INTEGER) AS decidim_scopes_id,
CAST(NULL AS BOOLEAN) AS supports_required,
CAST(NULL AS TIMESTAMP) AS created_at,
CAST(NULL AS TIMESTAMP) AS updated_at
LIMIT 0
{% endif %}

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{% set relation = adapter.get_relation(
database=target.database,
schema='public',
identifier='decidim_initiatives_votes'
) %}

{% if relation is not none %}
SELECT
id,
decidim_initiative_id,
decidim_author_id,
created_at,
updated_at,
encrypted_metadata,
timestamp,
hash_id,
decidim_scope_id
FROM {{ source('decidim', 'decidim_initiatives_votes') }}
{% else %}
SELECT
CAST(NULL AS INTEGER) AS id,
CAST(NULL AS INTEGER) AS decidim_initiative_id,
CAST(NULL AS INTEGER) AS decidim_author_id,
CAST(NULL AS TIMESTAMP) AS created_at,
CAST(NULL AS TIMESTAMP) AS updated_at,
CAST(NULL AS TEXT) AS encrypted_metadata,
CAST(NULL AS TIMESTAMP) AS timestamp,
CAST(NULL AS TEXT) AS hash_id,
CAST(NULL AS INTEGER) AS decidim_scope_id
LIMIT 0
{% endif %}
1 change: 1 addition & 0 deletions projects/demo/models/staging/decidim/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ sources:
- name: decidim_endorsements
- name: decidim_follows
- name: decidim_initiatives
- name: decidim_initiatives_votes
- name: decidim_initiatives_type_scopes
- name: decidim_surveys_surveys
- name: decidim_attachments
Expand Down
1 change: 0 additions & 1 deletion projects/loire_atlantique/packages.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
packages:
- local: ../demo
- local: ../packages/initiatives
- package: dbt-labs/dbt_utils
version: 1.2.0
35 changes: 0 additions & 35 deletions projects/packages/initiatives/dbt_project.yml

This file was deleted.

42 changes: 0 additions & 42 deletions projects/packages/initiatives/models/staging/schema.yml

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit 86b65a4

Please sign in to comment.