Make sure hot rank sorts for post and community filter by positive hot ranks.

- Context #2994
This commit is contained in:
Dessalines 2023-07-05 15:10:02 -04:00
parent 2158621bda
commit 07c8f5348c
2 changed files with 11 additions and 3 deletions

View file

@ -391,8 +391,12 @@ impl<'a> PostQuery<'a> {
}
query = match self.sort.unwrap_or(SortType::Hot) {
SortType::Active => query.then_order_by(post_aggregates::hot_rank_active.desc()),
SortType::Hot => query.then_order_by(post_aggregates::hot_rank.desc()),
SortType::Active => query
.filter(post_aggregates::hot_rank_active.gt(1))
.then_order_by(post_aggregates::hot_rank_active.desc()),
SortType::Hot => query
.filter(post_aggregates::hot_rank.gt(1))
.then_order_by(post_aggregates::hot_rank.desc()),
SortType::New => query.then_order_by(post_aggregates::published.desc()),
SortType::Old => query.then_order_by(post_aggregates::published.asc()),
SortType::NewComments => query.then_order_by(post_aggregates::newest_comment_time.desc()),

View file

@ -184,7 +184,11 @@ impl<'a> CommunityQuery<'a> {
);
}
match self.sort.unwrap_or(Hot) {
Hot | Active => query = query.order_by(community_aggregates::hot_rank.desc()),
Hot | Active => {
query = query
.filter(community_aggregates::hot_rank.gt(1))
.order_by(community_aggregates::hot_rank.desc())
}
NewComments | TopDay | TopTwelveHour | TopSixHour | TopHour => {
query = query.order_by(community_aggregates::users_active_day.desc())
}