]> Untitled Git - lemmy.git/commitdiff
Adding users active monthly for community sort. Fixes #1527
authorDessalines <tyhou13@gmx.com>
Thu, 1 Apr 2021 18:34:27 +0000 (14:34 -0400)
committerDessalines <tyhou13@gmx.com>
Thu, 1 Apr 2021 18:34:27 +0000 (14:34 -0400)
crates/db_views_actor/src/community_view.rs
migrations/2021-04-01-181826_add_community_agg_active_monthly_index/down.sql [new file with mode: 0644]
migrations/2021-04-01-181826_add_community_agg_active_monthly_index/up.sql [new file with mode: 0644]

index fe3a80bb7189b0572cd02f8765eb3ffbe83eceac..87b9cbcf16748181bd4f4638ba9e95331b1d72fd 100644 (file)
@@ -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 (file)
index 0000000..9748bc1
--- /dev/null
@@ -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 (file)
index 0000000..4ae90e0
--- /dev/null
@@ -0,0 +1,2 @@
+create index idx_community_aggregates_users_active_month on community_aggregates (users_active_month desc);
+