Skip to content

Commit

Permalink
feat(demo): count managed non-confirmed users in users model
Browse files Browse the repository at this point in the history
  • Loading branch information
hellpe committed Feb 27, 2025
1 parent 4a919ae commit aecf271
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
18 changes: 17 additions & 1 deletion projects/demo/models/marts/users/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,23 @@ unit_tests:
expect:
format: dict
rows:
- {id: 2}
- {id: 2}
- name: managed_and_confirmed_users_check
description: "Check that only managed users are retrieved among unconfirmed users"
model: users
given:
- input: ref('all_users')
format: dict
rows:
- {id: 1, deleted_at: NULL, blocked: false, admin: false, managed: false, confirmed: true}
- {id: 2, deleted_at: NULL, blocked: false, admin: false, managed: true, confirmed: false}
- {id: 3, deleted_at: NULL, blocked: false, admin: false, managed: false, confirmed: false}
expect:
format: dict
rows:
- {id: 1}
- {id: 2}

# - name: test_url_concatenation
# description: "Check URL concatenation logic"
# model: all_users
Expand Down
2 changes: 1 addition & 1 deletion projects/demo/models/marts/users/users.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ SELECT
WHERE deleted_at IS NULL
AND decidim_users.blocked != true
AND decidim_users.admin != true
AND decidim_users.confirmed = true
AND (decidim_users.confirmed = true OR decidim_users.managed = true)
4 changes: 2 additions & 2 deletions projects/marseille/models/marts/users_with_promote_info.sql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ WITH promote_actions AS (
decidim_action_logs.id AS log_id,
action
FROM {{ ref('stg_decidim_action_logs') }} AS decidim_action_logs
LEFT JOIN {{ ref('all_users') }} AS users ON users.id = decidim_action_logs.resource_id
LEFT JOIN {{ ref('users') }} AS users ON users.id = decidim_action_logs.resource_id
WHERE resource_type = 'Decidim::User'
AND action = 'promote'
)
Expand All @@ -18,5 +18,5 @@ SELECT
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('all_users') }} AS users
FROM {{ ref('users') }} AS users
LEFT JOIN promote_actions ON users.id = promote_actions.user_id

0 comments on commit aecf271

Please sign in to comment.