From b893085d1fc73b60468b35cfef0d5e007173ca49 Mon Sep 17 00:00:00 2001 From: Dessalines Date: Thu, 1 Apr 2021 14:34:27 -0400 Subject: [PATCH] Adding users active monthly for community sort. Fixes #1527 --- crates/db_views_actor/src/community_view.rs | 1 + .../down.sql | 1 + .../up.sql | 2 ++ 3 files changed, 4 insertions(+) create mode 100644 migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql create mode 100644 migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql 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); +