]> Untitled Git - lemmy.git/blobdiff - crates/db_views_actor/src/comment_reply_view.rs
Addressing slow profile queries. #2777 (#2830)
[lemmy.git] / crates / db_views_actor / src / comment_reply_view.rs
index c9a3d971355ae354b111cf8b97edd9d8f58b0d4a..2a3c58d6ca2b019bddb10f683b41cf05b188de7c 100644 (file)
@@ -1,6 +1,5 @@
 use crate::structs::CommentReplyView;
 use diesel::{
-  dsl::now,
   result::Error,
   BoolExpressionMethods,
   ExpressionMethods,
@@ -91,12 +90,7 @@ impl CommentReplyView {
         community_person_ban::table.on(
           community::id
             .eq(community_person_ban::community_id)
-            .and(community_person_ban::person_id.eq(comment::creator_id))
-            .and(
-              community_person_ban::expires
-                .is_null()
-                .or(community_person_ban::expires.gt(now)),
-            ),
+            .and(community_person_ban::person_id.eq(comment::creator_id)),
         ),
       )
       .left_join(
@@ -212,12 +206,7 @@ impl<'a> CommentReplyQuery<'a> {
         community_person_ban::table.on(
           community::id
             .eq(community_person_ban::community_id)
-            .and(community_person_ban::person_id.eq(comment::creator_id))
-            .and(
-              community_person_ban::expires
-                .is_null()
-                .or(community_person_ban::expires.gt(now)),
-            ),
+            .and(community_person_ban::person_id.eq(comment::creator_id)),
         ),
       )
       .left_join(
@@ -276,12 +265,12 @@ impl<'a> CommentReplyQuery<'a> {
       query = query.filter(person::bot_account.eq(false));
     };
 
-    query = match self.sort.unwrap_or(CommentSortType::Hot) {
+    query = match self.sort.unwrap_or(CommentSortType::New) {
       CommentSortType::Hot => query
         .then_order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
         .then_order_by(comment_aggregates::published.desc()),
-      CommentSortType::New => query.then_order_by(comment::published.desc()),
-      CommentSortType::Old => query.then_order_by(comment::published.asc()),
+      CommentSortType::New => query.then_order_by(comment_reply::published.desc()),
+      CommentSortType::Old => query.then_order_by(comment_reply::published.asc()),
       CommentSortType::Top => query.order_by(comment_aggregates::score.desc()),
     };