Skip to content

Commit

Permalink
alter courserun mart total engagement counts to pick up engagement no…
Browse files Browse the repository at this point in the history
…t captured by course structure (#1465)

* alter courserun engagement counts to pick up engagement not captured by course structure table
  • Loading branch information
KatelynGit authored Feb 10, 2025
1 parent f5c1dc9 commit bf2e815
Showing 1 changed file with 62 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,12 +215,42 @@ with combined_engagements as (
, courserun_readable_id
)

, user_video_correction as (
select
platform
, courserun_readable_id
, max(videos_user_watched) as max_videos_per_courserun
from combined_user_video
group by
platform
, courserun_readable_id
)

, user_problem_correction as (
select
platform
, courserun_readable_id
, max(problems_user_submitted) as max_problems_per_courserun
from combined_user_problem
group by
platform
, courserun_readable_id
)

, user_discussion_correction as (
select
platform
, courserun_readable_id
, max(user_discussion_count) as max_discussions_per_courserun
from combined_user_discussion
group by
platform
, courserun_readable_id
)

select
combined_runs.platform
, combined_runs.courserun_readable_id
, combined_engagements.total_courserun_problems
, combined_engagements.total_courserun_videos
, combined_engagements.total_courserun_discussions
, combined_runs.courserun_title
, combined_runs.course_readable_id
, combined_runs.courserun_is_current
Expand All @@ -230,6 +260,23 @@ select
, combined_user_video.videos_user_watched
, combined_user_problem.problems_user_submitted
, combined_user_discussion.user_discussion_count
, case
when combined_engagements.total_courserun_problems >= user_problem_correction.max_problems_per_courserun
then combined_engagements.total_courserun_problems
else user_problem_correction.max_problems_per_courserun
end as total_courserun_problems
, case
when combined_engagements.total_courserun_videos >= user_video_correction.max_videos_per_courserun
then combined_engagements.total_courserun_videos
else user_video_correction.max_videos_per_courserun
end as total_courserun_videos
, case
when
combined_engagements.total_courserun_discussions
>= user_discussion_correction.max_discussions_per_courserun
then combined_engagements.total_courserun_discussions
else user_discussion_correction.max_discussions_per_courserun
end as total_courserun_discussions
from combined_runs
inner join combined_engagements
on
Expand All @@ -254,3 +301,15 @@ left join combined_user_discussion
combined_enrollments.courserun_readable_id = combined_user_discussion.courserun_readable_id
and combined_enrollments.platform = combined_user_discussion.platform
and combined_enrollments.user_username = combined_user_discussion.user_username
left join user_video_correction
on
combined_runs.courserun_readable_id = user_video_correction.courserun_readable_id
and combined_runs.platform = user_video_correction.platform
left join user_problem_correction
on
combined_runs.courserun_readable_id = user_problem_correction.courserun_readable_id
and combined_runs.platform = user_problem_correction.platform
left join user_discussion_correction
on
combined_runs.courserun_readable_id = user_discussion_correction.courserun_readable_id
and combined_runs.platform = user_discussion_correction.platform

0 comments on commit bf2e815

Please sign in to comment.