diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index fe3a80bb7..87b9cbcf1 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views_actor/src/community_view.rs @@ -193,6 +193,7 @@ impl<'a> CommunityQueryBuilder<'a> { match self.sort { SortType::New => query = query.order_by(community::published.desc()), SortType::TopAll => query = query.order_by(community_aggregates::subscribers.desc()), + SortType::TopMonth => query = query.order_by(community_aggregates::users_active_month.desc()), // Covers all other sorts, including hot _ => { query = query diff --git a/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql b/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql new file mode 100644 index 000000000..9748bc17f --- /dev/null +++ b/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql @@ -0,0 +1 @@ +drop index idx_community_aggregates_users_active_month; diff --git a/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql b/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql new file mode 100644 index 000000000..4ae90e0ab --- /dev/null +++ b/migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql @@ -0,0 +1,2 @@ +create index idx_community_aggregates_users_active_month on community_aggregates (users_active_month desc); +