Skip to content

Commit

Permalink
Add secondary sort by published date for post view (fixes #4383) (#4384)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic authored Jan 22, 2024
1 parent e78fe5a commit 0868910
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions crates/db_views/src/post_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 0868910

Please sign in to comment.