X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_views%2Fsrc%2Fcomment_view.rs;h=0615d9517eb10d300326fc5a9f2025aade0abc3d;hb=1b5437cbe3fe0b9726c5760c05f52054ab4e54c2;hp=ea967fdff69e4a9dc05b28787d982096ba72b682;hpb=17527d0e7e8c9fd3cc16aa41c636432b7b6b5650;p=lemmy.git diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index ea967fdf..0615d951 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -1,6 +1,5 @@ use crate::structs::CommentView; use diesel::{ - dsl::now, result::Error, BoolExpressionMethods, ExpressionMethods, @@ -88,12 +87,7 @@ impl CommentView { 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( @@ -199,12 +193,7 @@ impl<'a> CommentQuery<'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( @@ -279,6 +268,10 @@ impl<'a> CommentQuery<'a> { query = query.filter(comment::content.ilike(fuzzy_search(&search_term))); }; + if let Some(community_id) = self.community_id { + query = query.filter(post::community_id.eq(community_id)); + } + if let Some(listing_type) = self.listing_type { match listing_type { ListingType::Subscribed => { @@ -299,10 +292,6 @@ impl<'a> CommentQuery<'a> { ) } } - }; - - if let Some(community_id) = self.community_id { - query = query.filter(post::community_id.eq(community_id)); } if self.saved_only.unwrap_or(false) { @@ -610,6 +599,7 @@ mod tests { let read_comment_views_no_person = CommentQuery::builder() .pool(pool) + .sort(Some(CommentSortType::Hot)) .post_id(Some(data.inserted_post.id)) .build() .list() @@ -623,6 +613,7 @@ mod tests { let read_comment_views_with_person = CommentQuery::builder() .pool(pool) + .sort(Some(CommentSortType::Hot)) .post_id(Some(data.inserted_post.id)) .local_user(Some(&data.inserted_local_user)) .build()