From b4315d7b47d9ffedf73861e4e073e133f93295fe Mon Sep 17 00:00:00 2001 From: Cristhian Garcia Date: Tue, 27 Feb 2024 15:45:02 -0500 Subject: [PATCH] feat: add graded and block_type to dim_course_blocks --- models/base/dim_course_blocks.sql | 12 +++++++++++- models/base/schema.yml | 5 +++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/models/base/dim_course_blocks.sql b/models/base/dim_course_blocks.sql index 941bba1..b4b37d9 100644 --- a/models/base/dim_course_blocks.sql +++ b/models/base/dim_course_blocks.sql @@ -5,7 +5,17 @@ select courses.course_run as course_run, blocks.location as block_id, blocks.block_name as block_name, - blocks.display_name_with_location as display_name_with_location + blocks.display_name_with_location as display_name_with_location, + graded, + case + when block_id like '%@chapter+block@%' + then 'section' + when block_id like '%@sequential+block@%' + then 'subsection' + when block_id like '%@vertical+block@%' + then 'unit' + else regexpExtract(block_id, '@([^+]+)\+block@', 1) + end as block_type from {{ source("event_sink", "course_block_names") }} blocks join {{ source("event_sink", "course_names") }} courses diff --git a/models/base/schema.yml b/models/base/schema.yml index 04af7ee..98650fe 100644 --- a/models/base/schema.yml +++ b/models/base/schema.yml @@ -19,3 +19,8 @@ models: - name: display_name_with_location data_type: String description: "The block's display name with section, subsection, and unit prepended to the name. This provides additional context when looking at block names and can help data consumers understand which block they are analyzing" + - name: graded + data_type: Boolean + - name: block_type + data_type: String + description: "The type of block. This can be a section, subsection, unit, or the block type"