X-Git-Url: http://these/git/?a=blobdiff_plain;f=crates%2Fdb_views%2Fsrc%2Fpost_view.rs;h=4a36b816fbe7dc55545f873f80b3c2d74321d913;hb=9dfd819691676994ac52b000fc4f93dfe72bc2b3;hp=f5c8100fd186afd3dece252fcb1bce4dd581e80d;hpb=0ecf256ce32392b53b96a24ddd8f2e4e513281da;p=lemmy.git diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index f5c8100f..4a36b816 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -324,17 +324,16 @@ impl<'a> PostQuery<'a> { } } } - - if let Some(community_id) = self.community_id { + if self.community_id.is_none() && self.community_actor_id.is_none() { + query = query.then_order_by(post_aggregates::featured_local.desc()); + } else if let Some(community_id) = self.community_id { query = query .filter(post::community_id.eq(community_id)) - .then_order_by(post_aggregates::stickied.desc()); - } - - if let Some(community_actor_id) = self.community_actor_id { + .then_order_by(post_aggregates::featured_community.desc()); + } else if let Some(community_actor_id) = self.community_actor_id { query = query .filter(community::actor_id.eq(community_actor_id)) - .then_order_by(post_aggregates::stickied.desc()); + .then_order_by(post_aggregates::featured_community.desc()); } if let Some(url_search) = self.url_search { @@ -860,7 +859,6 @@ mod tests { removed: false, deleted: false, locked: false, - stickied: false, nsfw: false, embed_title: None, embed_description: None, @@ -869,6 +867,8 @@ mod tests { ap_id: inserted_post.ap_id.clone(), local: true, language_id: LanguageId(47), + featured_community: false, + featured_local: false, }, my_vote: None, unread_comments: 0, @@ -919,10 +919,11 @@ mod tests { score: 0, upvotes: 0, downvotes: 0, - stickied: false, published: agg.published, newest_comment_time_necro: inserted_post.published, newest_comment_time: inserted_post.published, + featured_community: false, + featured_local: false, }, subscribed: SubscribedType::NotSubscribed, read: false,