-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
temp: add example model with average per month
- Loading branch information
Showing
1 changed file
with
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{{ | ||
config( | ||
materialized="materialized_view", | ||
schema=env_var("ASPECTS_XAPI_DATABASE", "xapi"), | ||
engine=get_engine("ReplacingMergeTree()"), | ||
primary_key="(year, month)", | ||
order_by="(year, month)", | ||
partition_by="", | ||
) | ||
}} | ||
|
||
|
||
with | ||
grades_average as ( | ||
select | ||
course_key, | ||
monthName(emission_time) as month_name, | ||
toYear(emission_time) as year, | ||
case | ||
when verb_id = 'http://adlnet.gov/expapi/verbs/passed' then 1 else 0 | ||
end as approving, | ||
count(1) as total | ||
from xapi.grading_events | ||
where | ||
verb_id in ( | ||
'http://adlnet.gov/expapi/verbs/passed', | ||
'http://adlnet.gov/expapi/verbs/failed' | ||
) | ||
group by course_key, year, month_name, approving | ||
having approving = 1 | ||
) | ||
|
||
select year, month_name, avg(total) | ||
from grades_average | ||
group by year, month_name |