diff --git a/models/grading/fact_student_status.sql b/models/grading/fact_student_status.sql index 4d9cd9e..4ffc787 100644 --- a/models/grading/fact_student_status.sql +++ b/models/grading/fact_student_status.sql @@ -13,7 +13,7 @@ select users.name as name, users.email as email, fes.emission_time as enrolled_at -from {{ ref("fact_enrollment_status") }} fes +from {{ ref("fact_enrollment_status") }} fes FINAL left join {{ ref("fact_learner_course_status") }} lg on fes.org = lg.org diff --git a/models/grading/unit_tests.yaml b/models/grading/unit_tests.yaml index 679e7a5..83c5c58 100644 --- a/models/grading/unit_tests.yaml +++ b/models/grading/unit_tests.yaml @@ -38,33 +38,3 @@ unit_tests: expect: format: csv fixture: fact_learner_course_status_expected - - - name: test_fact_student_status - model: fact_student_status - config: - tags: 'ci' - given: - - input: ref('fact_enrollment_status') - format: sql - rows: | - select * from fact_enrollment_status - - input: ref('fact_learner_course_status') - format: sql - rows: | - select * from fact_learner_course_status - - input: ref('fact_learner_course_grade') - format: sql - rows: | - select * from fact_learner_course_grade - - input: ref('course_names') - format: sql - rows: | - select * from course_names - - input: ref('dim_user_pii') - format: sql - rows: | - select * from dim_user_pii - expect: - format: sql - rows: | - select * from fact_student_status_expected diff --git a/models/video/schema.yml b/models/video/schema.yml index 00ac8ff..e9edec3 100644 --- a/models/video/schema.yml +++ b/models/video/schema.yml @@ -250,9 +250,9 @@ models: - name: actor_id data_type: string description: "The xAPI actor identifier" - - name: video_id - data_type: String - description: "The xAPI object identifier" + - name: video_count + data_type: Int32 + description: "Count of videos per course_key" - name: video_duration data_type: Int32 description: "Total duration of the video" diff --git a/models/video/watched_video_duration.sql b/models/video/watched_video_duration.sql index 68fdc69..3305704 100644 --- a/models/video/watched_video_duration.sql +++ b/models/video/watched_video_duration.sql @@ -3,7 +3,7 @@ materialized="materialized_view", schema=env_var("ASPECTS_XAPI_DATABASE", "xapi"), engine=get_engine("ReplacingMergeTree()"), - order_by="(org,course_key,actor_id,video_id)", + order_by="(org,course_key,actor_id)", post_hook="OPTIMIZE TABLE {{ this }} {{ on_cluster() }} FINAL", ) }} @@ -86,13 +86,19 @@ with ) ) and b.start_emission_time > a.start_emission_time + ), + course_data as ( + select org, course_key, count(distinct block_id) video_count + from {{ ref('dim_course_blocks') }} + where block_type = 'video' + group by org, course_key ) select - org, - course_key, + course_data.org as org, + course_data.course_key as course_key, range.actor_id as actor_id, - video_id, video_duration, + video_count, sum( case when r1.actor_id = '' and r2.actor_id = '' @@ -107,7 +113,8 @@ select else 0 end ) as rewatched_time -from range +from course_data +left join range on range.course_key = course_data.course_key left join rewatched r1 on range.event_id = r1.event_id1 left join rewatched r2 on range.event_id = r2.event_id2 -group by org, course_key, actor_id, video_id, video_duration +group by org, course_key, actor_id, video_count, video_duration