Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add course licensing model. #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions models/course_licensing/institution_administrators_count.sql
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
12 changes: 12 additions & 0 deletions models/course_licensing/schema.yml
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."
20 changes: 20 additions & 0 deletions models/course_licensing/sources.yml
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
2 changes: 1 addition & 1 deletion packages.yml
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