Skip to content

Commit

Permalink
Sort by post id in post view (#4270)
Browse files Browse the repository at this point in the history
* Sort by post id in post view

* Remove tie_breaker

---------

Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Nutomic <me@nutomic.com>
  • Loading branch information
3 people committed Dec 15, 2023
1 parent 7a182c9 commit a7ba5c9
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions crates/db_views/src/post_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,10 @@ fn queries<'a>() -> Queries<
query = query.filter(post_aggregates::published.gt(now() - interval));
}

let tie_breaker = match options.sort.unwrap_or(SortType::Hot) {
// A second time-based sort would not be very useful
SortType::New | SortType::Old | SortType::NewComments => None,
_ => Some((Ord::Desc, field!(published))),
};

let sorts = [
Some((Ord::Desc, featured_field)),
Some(main_sort),
tie_breaker,
Some((Ord::Desc, field!(post_id))),
];
let sorts_iter = sorts.iter().flatten();

Expand Down

0 comments on commit a7ba5c9

Please sign in to comment.