Skip to content

Commit

Permalink
feat: add course_licensing model.
Browse files Browse the repository at this point in the history
  • Loading branch information
anfbermudezme committed Sep 4, 2024
1 parent 61b8cb1 commit b01edb6
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 1 deletion.
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

0 comments on commit b01edb6

Please sign in to comment.