TopMonth,
TopYear,
TopAll,
+ MostComments,
}
#[derive(EnumString, ToString, Debug, Serialize, Deserialize, Clone)]
SortType::Hot | SortType::Active => query
.order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
.then_order_by(comment_aggregates::published.desc()),
- SortType::New => query.order_by(comment::published.desc()),
+ SortType::New | SortType::MostComments => query.order_by(comment::published.desc()),
SortType::TopAll => query.order_by(comment_aggregates::score.desc()),
SortType::TopYear => query
.filter(comment::published.gt(now - 1.years()))
.then_order_by(hot_rank(post_aggregates::score, post_aggregates::published).desc())
.then_order_by(post_aggregates::published.desc()),
SortType::New => query.then_order_by(post_aggregates::published.desc()),
+ SortType::MostComments => query.then_order_by(post_aggregates::comments.desc()),
SortType::TopAll => query.then_order_by(post_aggregates::score.desc()),
SortType::TopYear => query
.filter(post::published.gt(now - 1.years()))
SortType::Hot | SortType::Active => query
.order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
.then_order_by(comment_aggregates::published.desc()),
- SortType::New => query.order_by(comment::published.desc()),
+ SortType::New | SortType::MostComments => query.order_by(comment::published.desc()),
SortType::TopAll => query.order_by(comment_aggregates::score.desc()),
SortType::TopYear => query
.filter(comment::published.gt(now - 1.years()))
SortType::Active => query
.order_by(user_aggregates::comment_score.desc())
.then_order_by(user_::published.desc()),
- SortType::New => query.order_by(user_::published.desc()),
+ SortType::New | SortType::MostComments => query.order_by(user_::published.desc()),
SortType::TopAll => query.order_by(user_aggregates::comment_score.desc()),
SortType::TopYear => query
.filter(user_::published.gt(now - 1.years()))
--- /dev/null
+drop index idx_post_aggregates_comments;
--- /dev/null
+create index idx_post_aggregates_comments on post_aggregates (comments desc);