Skip to content

Commit

Permalink
feat: add fact_current_enrollments model
Browse files Browse the repository at this point in the history
  • Loading branch information
Ian2012 committed May 30, 2024
1 parent a20f45e commit 401d788
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
23 changes: 23 additions & 0 deletions models/enrollment/fact_current_enrollments.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
with
enrollments as (
select
org, course_key, actor_id, enrollment_status, enrollment_mode, emission_time
from {{ ref("fact_enrollment_status") }}
)

select
enrollments.emission_time as emission_time,
enrollments.org as org,
enrollments.course_key as course_key,
courses.course_name as course_name,
courses.course_run as course_run,
enrollments.actor_id as actor_id,
enrollments.enrollment_mode as enrollment_mode,
enrollments.enrollment_status as enrollment_status,
users.username as username,
users.name as name,
users.email as email
from enrollments
join {{ ref("course_names") }} courses on enrollments.course_key = courses.course_key
left outer join
{{ ref("dim_user_pii") }} users on toUUID(actor_id) = users.external_user_id
40 changes: 40 additions & 0 deletions models/enrollment/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,43 @@ models:
- name: emission_time
data_type: datetime
description: "The time the enrollment status was emitted"

- name: fact_current_enrollments
description: "One record per learner per course for the most recent enrollment status with additional learner information"
columns:
- name: emission_time
data_type: DateTime
description: "Timestamp, to the second, of when this event was emitted"
- name: org
data_type: String
description: "The organization that the course belongs to"
- name: course_key
data_type: String
description: "The course key for the course"
- name: course_name
data_type: String
description: "The name of the course"
- name: course_run
data_type: String
description: "The course run for the course"
- name: actor_id
data_type: String
description: "The xAPI actor identifier"
- name: enrollment_mode
data_type: LowCardinality(String)
description: "The mode of enrollment"
- name: enrollment_status
description: "Whether a learner is actively enrolled in a course"
tests:
- accepted_values:
values: ["registered", "unregistered"]
data_type: String
- name: username
data_type: String
description: "The username of the learner"
- name: name
data_type: String
description: "The full name of the learner"
- name: email
data_type: String
description: "The email address of the learner"

0 comments on commit 401d788

Please sign in to comment.