-
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.
- Loading branch information
Showing
5 changed files
with
41 additions
and
5 deletions.
There are no files selected for viewing
8 changes: 4 additions & 4 deletions
8
projects/marseille/models/marts/proposals_with_impersonation_info.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,14 +1,14 @@ | ||
WITH proposals_under_impersonation AS ( | ||
SELECT | ||
proposals.id AS proposal_id | ||
FROM {{ ref("proposals") }} AS proposals | ||
LEFT JOIN {{ ref("decidim_impersonation_logs") }} AS impersonations ON proposals.first_author_id = impersonations.user_id | ||
proposals.id AS proposal_id | ||
FROM {{ ref('proposals') }} AS proposals | ||
LEFT JOIN {{ ref('stg_decidim_impersonation_logs') }} AS impersonations ON proposals.first_author_id = impersonations.user_id | ||
WHERE proposals.created_at BETWEEN impersonations.started_at AND impersonations.ended_at | ||
ORDER BY proposals.id | ||
) | ||
|
||
SELECT | ||
*, | ||
(CASE WHEN proposals_under_impersonation.proposal_id IS NOT NULL THEN true ELSE false END) AS authored_under_impersonation | ||
FROM {{ ref("proposals") }} AS proposals | ||
FROM {{ ref('proposals') }} AS proposals | ||
LEFT JOIN proposals_under_impersonation ON proposals.id = proposals_under_impersonation.proposal_id |
22 changes: 22 additions & 0 deletions
22
projects/marseille/models/marts/users_with_promote_info.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,22 @@ | ||
WITH promote_actions AS ( | ||
SELECT | ||
DISTINCT ON (users.id) | ||
users.id AS user_id, | ||
decidim_action_logs.id AS log_id, | ||
action | ||
FROM {{ ref('stg_decidim_action_logs') }} AS decidim_action_logs | ||
LEFT JOIN {{ ref('users') }} AS users ON users.id = decidim_action_logs.resource_id | ||
WHERE resource_type = 'Decidim::User' | ||
AND action = 'promote' | ||
) | ||
|
||
SELECT | ||
users.*, | ||
(CASE | ||
WHEN promote_actions.action IS NOT NULL AND users.managed = false THEN 'Confirmée' | ||
WHEN promote_actions.action IS NOT NULL AND users.managed = true THEN 'En attente' | ||
WHEN promote_actions.action IS NULL AND users.managed = false THEN 'Utilisateur non représenté' | ||
ELSE 'Non proposée' | ||
END) AS promotion_status | ||
FROM {{ ref('users') }} AS users | ||
LEFT JOIN promote_actions ON users.id = promote_actions.user_id |
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
13 changes: 13 additions & 0 deletions
13
projects/marseille/models/staging/decidim/stg_decidim_action_logs.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,13 @@ | ||
WITH source AS ( | ||
SELECT * FROM {{ source('decidim', 'decidim_action_logs') }} | ||
) | ||
|
||
SELECT | ||
id, | ||
created_at, | ||
updated_at, | ||
decidim_user_id, | ||
action, | ||
resource_type, | ||
resource_id | ||
FROM source |
File renamed without changes.