diff --git a/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/01_create_view.sql b/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/01_create_view.sql index 1a64bc6ee8..d469fd28ac 100644 --- a/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/01_create_view.sql +++ b/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/01_create_view.sql @@ -1,9 +1,9 @@ -DROP VIEW IF EXISTS report.group_bubble_type_counts CASCADE; +DROP VIEW IF EXISTS report.group_bubbled_type_counts CASCADE; -- A weekly count of annotation type, but with counts summed -- up and down between parents and children as appropriate. -CREATE MATERIALIZED VIEW report.group_bubble_type_counts AS ( +CREATE MATERIALIZED VIEW report.group_bubbled_type_counts AS ( SELECT created_week, group_to_group.parent_id AS group_id, diff --git a/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/02_initial_fill.sql b/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/02_initial_fill.sql index ade8dda822..4121c4ea94 100644 --- a/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/02_initial_fill.sql +++ b/lms/data_tasks/report/create_from_scratch/04_activity_counts/01_groups/05_group_bubbled_type_counts/02_initial_fill.sql @@ -1,8 +1,9 @@ -DROP INDEX IF EXISTS report.group_bubbled_activity_created_week_group_id_idx; +DROP INDEX IF EXISTS report.group_bubbled_type_count_created_week_group_id_idx; -REFRESH MATERIALIZED VIEW report.group_bubbled_activity; +REFRESH MATERIALIZED VIEW report.group_bubbled_type_count; -ANALYSE report.group_bubbled_activity; +ANALYSE report.group_bubbled_type_count; -- A unique index is mandatory for concurrent updates used in the refresh -CREATE UNIQUE INDEX group_bubbled_activity_created_week_group_id_idx ON report.group_bubbled_activity (created_week, group_id); +CREATE UNIQUE INDEX group_bubbled_type_count_created_week_group_id_idx + ON report.group_bubbled_type_count (created_week, group_id, sub_type, shared);