From 0868910570217b8b3946afb69fd8b058db7a70cb Mon Sep 17 00:00:00 2001 From: Nutomic Date: Mon, 22 Jan 2024 14:52:21 +0100 Subject: [PATCH] Add secondary sort by published date for post view (fixes #4383) (#4384) --- crates/db_views/src/post_view.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 0b93c6186..4ca72e345 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -492,8 +492,14 @@ fn queries<'a>() -> Queries< } let sorts = [ + // featured posts first Some((Ord::Desc, featured_field)), + // then use the main sort Some(main_sort), + // hot rank reaches zero after some days, use publish as fallback. necessary because old + // posts can be fetched over federation and inserted with high post id + Some((Ord::Desc, field!(published))), + // finally use unique post id as tie breaker Some((Ord::Desc, field!(post_id))), ]; let sorts_iter = sorts.iter().flatten();