Skip to content

Commit

Permalink
fix: view only the highest level of completion reached for each block…
Browse files Browse the repository at this point in the history
… + user

and adds a test
  • Loading branch information
pomegranited committed Jun 27, 2024
1 parent 5cf7331 commit 66e4d0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion models/completion_aggregator/fact_aggregated_completions.sql
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ with
splitByString('/course/', object_id)[-1],
splitByString('/xblock/', object_id)[-1]
) as entity_id,
cast(progress_percent as Float) / 100 as scaled_progress
cast(progress_percent as Float) / 100 as scaled_progress,
row_number() over (
partition by org, entity_id, actor_id order by scaled_progress desc
) as rn
from {{ ref("aggregated_completion_events") }}
)

Expand Down Expand Up @@ -59,3 +62,4 @@ left join
left outer join
{{ ref("dim_user_pii") }} users
on toUUID(completions.actor_id) = users.external_user_id
where rn = 1
4 changes: 4 additions & 0 deletions tests/generic/test_completion_uniqueness.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
select org, entity_id, actor_id, count(*) as num_rows
from {{ ref("fact_aggregated_completions") }}
group by org, entity_id, actor_id
having num_rows > 1

0 comments on commit 66e4d0f

Please sign in to comment.