-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61b8cb1
commit b01edb6
Showing
4 changed files
with
56 additions
and
1 deletion.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
models/course_licensing/institution_administrators_count.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,23 @@ | ||
{{ | ||
config( | ||
materialized="materialized_view", | ||
schema=env_var("ASPECTS_EVENT_SINK_DATABASE", "event_sink"), | ||
post_hook="OPTIMIZE TABLE {{ this }} {{ on_cluster }} FINAL" | ||
) | ||
}} | ||
|
||
SELECT | ||
institution_id, | ||
count(id) as institution_administrator_count | ||
FROM {{ source("event_sink", "course_licensing_institution_administrator") }} institution_administrator | ||
JOIN | ||
( | ||
SELECT | ||
id, | ||
max(time_last_dumped) as max_time_last_dumped | ||
FROM {{ source("event_sink", "course_licensing_institution_administrator") }} | ||
GROUP BY id | ||
) latest_institution_administrators | ||
ON institution_administrator.id = latest_institution_administrators.id | ||
AND institution_administrator.time_last_dumped = latest_institution_administrators.max_time_last_dumped | ||
GROUP BY institution_id |
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,12 @@ | ||
version: 2 | ||
|
||
models: | ||
- name: institution_administrators_count | ||
description: "Count of institution administrators by institution." | ||
columns: | ||
- name: institution_id | ||
data_type: Int32 | ||
description: "Id of the institution." | ||
- name: institution_administrator_count | ||
data_type: Int32 | ||
description: "Count of institution administrators for each institution." |
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,20 @@ | ||
version: 2 | ||
|
||
sources: | ||
- name: event_sink | ||
database: "{{ env_var('ASPECTS_EVENT_SINK_DATABASE', 'event_sink')}}" | ||
tables: | ||
|
||
- name: course_licensing_institution_administrator | ||
columns: | ||
- name: dump_id | ||
- name: time_last_dumped | ||
- name: id | ||
- name: created | ||
- name: modified | ||
- name: institution_id | ||
- name: institution_name | ||
- name: user_id | ||
- name: user_name | ||
- name: user_email | ||
- name: active |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
packages: | ||
- git: "https://github.com/openedx/aspects-dbt.git" | ||
revision: cag/course-block-perf | ||
revision: v3.30.0 |