-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add engagement totals mart table marts__combined_total_course_engagem…
…ents (#1444) * add engagement totals mart table marts__combined_total_course_engagements
- Loading branch information
1 parent
c30474d
commit 9f8f8f1
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/ol_dbt/models/marts/combined/marts__combined_total_course_engagements.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
with combined_engagements as ( | ||
select | ||
platform | ||
, courserun_readable_id | ||
, count( | ||
distinct | ||
case | ||
when coursestructure_block_category = 'discussion' | ||
then coursestructure_block_id | ||
end | ||
) as total_courserun_discussions | ||
, count( | ||
distinct | ||
case | ||
when coursestructure_block_category = 'video' | ||
then coursestructure_block_id | ||
end | ||
) as total_courserun_videos | ||
, count( | ||
distinct | ||
case | ||
when coursestructure_block_category = 'problem' | ||
then coursestructure_block_id | ||
end | ||
) as total_courserun_problems | ||
from {{ ref('int__combined__course_structure') }} | ||
group by | ||
platform | ||
, courserun_readable_id | ||
) | ||
|
||
, combined_runs as ( | ||
select * | ||
from {{ ref('int__combined__course_runs') }} | ||
where courserun_readable_id is not null | ||
) | ||
|
||
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 | ||
, combined_runs.courserun_start_on | ||
, combined_runs.courserun_end_on | ||
from combined_runs | ||
inner join combined_engagements | ||
on | ||
combined_runs.courserun_readable_id = combined_engagements.courserun_readable_id | ||
and combined_runs.platform = combined_engagements.platform |