-
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
2 changed files
with
26 additions
and
8 deletions.
There are no files selected for viewing
21 changes: 13 additions & 8 deletions
21
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,9 +1,14 @@ | ||
SELECT | ||
proposals.* | ||
--(CASE | ||
--WHEN proposals.created_at BETWEEN impersonations.started_at AND impersonations.ended_at THEN true ELSE false END | ||
--) AS authored_by_impersonation | ||
FROM {{ ref("proposals") }} AS proposals | ||
LEFT JOIN {{ ref("decidim_impersonation_logs") }} AS impersonations ON proposals.first_author_id = impersonations.user_id | ||
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 | ||
WHERE proposals.created_at BETWEEN impersonations.started_at AND impersonations.ended_at | ||
ORDER BY proposals.id | ||
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 | ||
LEFT JOIN proposals_under_impersonation ON proposals.id = proposals_under_impersonation.proposal_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
unit_tests: | ||
- name: | ||
description: "" | ||
model: proposals_with_impersonation_info | ||
given: | ||
- input: ref('') | ||
format: dict | ||
rows: | ||
- {} | ||
expect: | ||
format: dict | ||
rows: | ||
- {} |