From 30b343057a9e21aad7cedf25bf8a03fe3498ae42 Mon Sep 17 00:00:00 2001 From: Kate Delaney <134744245+KatelynGit@users.noreply.github.com> Date: Fri, 23 May 2025 07:50:14 -0400 Subject: [PATCH] add fields to allow filters to work for program summary report --- .../models/reporting/_reporting__models.yml | 12 ++++++++ .../reporting/program_summary_report.sql | 30 ++++++++++++++----- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/ol_dbt/models/reporting/_reporting__models.yml b/src/ol_dbt/models/reporting/_reporting__models.yml index e2f36ea25..bd0666a00 100644 --- a/src/ol_dbt/models/reporting/_reporting__models.yml +++ b/src/ol_dbt/models/reporting/_reporting__models.yml @@ -6,12 +6,24 @@ models: (audit and verified), certificates and program credentials aggregated for each program. columns: + - name: platform + description: str, name of the platform - name: program_name description: str, name of the program. If program is split over multiple tracks, the program name is the same for all tracks. e.g. Data, Economics, and Design of Policy tests: - not_null + - name: program_type + description: str, the type of the program. Possible values are 'MicroMasters', + 'XSeries' and 'Professional Certificate' + - name: program_track + description: str, name of the specific track for MicroMasters programs. For example, + Statistics and Data Science program has multiple tracks - General Track, Methods + Track, Social Sciences Track, and 'Time Series and Social Sciences Track'. + - name: program_readable_id + description: str, readable ID from xpro or mitxonline formatted as program-v1:{org}+{program + code} e.g.program-v1:xPRO+MLx - name: total_enrollments description: int, count of course enrollments in the program, aggregated by user_email and courserun_readable_id diff --git a/src/ol_dbt/models/reporting/program_summary_report.sql b/src/ol_dbt/models/reporting/program_summary_report.sql index 6e4062303..b3c0ac5b0 100644 --- a/src/ol_dbt/models/reporting/program_summary_report.sql +++ b/src/ol_dbt/models/reporting/program_summary_report.sql @@ -12,7 +12,9 @@ with program_enrollments as ( , aggregated_course_enrollments as ( select - program_courses.program_name + program_courses.platform + , program_courses.program_readable_id + , program_courses.program_name , count(distinct course_enrollments.courserun_readable_id || course_enrollments.user_email) as total_enrollments , count(distinct course_enrollments.user_email) as unique_users , count(distinct course_enrollments.user_country_code) as unique_countries @@ -42,20 +44,32 @@ with program_enrollments as ( ) as unique_course_certificate_earners from course_enrollments inner join program_courses on course_enrollments.course_readable_id = program_courses.course_readable_id - group by program_courses.program_name + group by + program_courses.platform + , program_courses.program_readable_id + , program_courses.program_name ) , aggregated_program_certificates as ( select - program_name - , count(distinct user_email) as program_certificates + program_type + , program_track + , program_readable_id + , count(distinct case when user_has_completed_program = true then user_email end) + as program_certificates from program_enrollments - where user_has_completed_program = true - group by program_name + group by + program_type + , program_track + , program_readable_id ) select - aggregated_course_enrollments.program_name + aggregated_course_enrollments.platform + , aggregated_course_enrollments.program_name + , aggregated_program_certificates.program_type + , aggregated_program_certificates.program_track + , aggregated_course_enrollments.program_readable_id , aggregated_course_enrollments.total_enrollments , aggregated_course_enrollments.unique_users , aggregated_course_enrollments.unique_countries @@ -66,4 +80,4 @@ select , aggregated_program_certificates.program_certificates from aggregated_course_enrollments left join aggregated_program_certificates - on aggregated_course_enrollments.program_name = aggregated_program_certificates.program_name + on aggregated_course_enrollments.program_readable_id = aggregated_program_certificates.program_readable_id