Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
saraburns1 committed Nov 18, 2024
1 parent 63c009d commit 82d640f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
41 changes: 21 additions & 20 deletions models/video/unit_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,23 +107,24 @@ unit_tests:
select * from fact_video_engagement_expected
# - name: test_watched_video_duration
# model: watched_video_duration
# config:
# tags: 'ci'
# given:
# - input: ref("video_playback_events")
# format: sql
# rows: |
# select * from video_playback_events
# - input: ref("dim_course_blocks")
# format: sql
# rows: |
# select * from dim_course_blocks
# overrides:
# vars:
# org_filter: 'Org0'
# expect:
# format: sql
# rows: |
# select * from watched_video_duration_expected
- name: test_watched_video_duration
model: watched_video_duration
config:
tags: 'ci'
given:
- input: ref("video_playback_events")
format: sql
rows: |
select * from video_playback_events
- input: ref("dim_course_blocks")
format: sql
rows: |
select * from dim_course_blocks
overrides:
vars:
org_filter_var: '[]'
course_key_filter_var: '[]'
expect:
format: sql
rows: |
select * from watched_video_duration_expected
11 changes: 7 additions & 4 deletions models/video/watched_video_duration.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% set org_filter_var = var('org_filter_var') or {org_filter:String} %}
{% set course_key_filter_var = var('course_key_filter_var') or {course_key_filter:String} %}

with
data as (
select
Expand All @@ -22,12 +25,12 @@ with
'https://w3id.org/xapi/video/verbs/seeked'
)
and (
({org_filter:String} <> '[]' and org in cast({org_filter:String}, 'Array(String)'))
or {org_filter:String} = '[]'
({{ org_filter_var }} <> '[]' and org in cast({{ org_filter_var }}, 'Array(String)'))
or {{ org_filter_var }} = '[]'
)
and (
({course_key_filter:String} <> '[]' and course_key in cast({course_key_filter:String}, 'Array(String)'))
or {course_key_filter:String} = '[]'
({{course_key_filter_var}} <> '[]' and course_key in cast({{course_key_filter_var}}, 'Array(String)'))
or {{course_key_filter_var}} = '[]'
)
),
matches as (
Expand Down

0 comments on commit 82d640f

Please sign in to comment.