Skip to content

Commit

Permalink
complete model, unit test pending
Browse files Browse the repository at this point in the history
  • Loading branch information
hellpe committed Oct 30, 2024
1 parent c30d235 commit ff2ab5e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
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
13 changes: 13 additions & 0 deletions projects/marseille/models/marts/schema.yml
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:
- {}

0 comments on commit ff2ab5e

Please sign in to comment.