Sort by post id in post view (#4270)

* 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>
This commit is contained in:
dullbananas 2023-12-15 04:42:28 -07:00 committed by GitHub
parent 7a182c982b
commit a7ba5c9dd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -490,16 +490,10 @@ fn queries<'a>() -> Queries<
query = query.filter(post_aggregates::published.gt(now() - interval)); 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 = [ let sorts = [
Some((Ord::Desc, featured_field)), Some((Ord::Desc, featured_field)),
Some(main_sort), Some(main_sort),
tie_breaker, Some((Ord::Desc, field!(post_id))),
]; ];
let sorts_iter = sorts.iter().flatten(); let sorts_iter = sorts.iter().flatten();