From: Dessalines Date: Thu, 1 Apr 2021 18:34:27 +0000 (-0400) Subject: Adding users active monthly for community sort. Fixes #1527 X-Git-Url: http://these/git/%22https:/join-lemmy.org/static/%24%7Bargs.pageFn.jump%20n%7D?a=commitdiff_plain;h=b893085d1fc73b60468b35cfef0d5e007173ca49;p=lemmy.git Adding users active monthly for community sort. Fixes #1527 --- diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index fe3a80bb..87b9cbcf 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 00000000..9748bc17 --- /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 00000000..4ae90e0a --- /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); +