mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-11-10 02:05:10 +00:00
* Adding forum sort for post_aggregates. Fixes #1312 * Changing sort name from forum to MostComments.
This commit is contained in:
parent
f4d33389a5
commit
6bb4f0b41f
|
@ -164,6 +164,7 @@ pub enum SortType {
|
||||||
TopMonth,
|
TopMonth,
|
||||||
TopYear,
|
TopYear,
|
||||||
TopAll,
|
TopAll,
|
||||||
|
MostComments,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(EnumString, ToString, Debug, Serialize, Deserialize, Clone)]
|
#[derive(EnumString, ToString, Debug, Serialize, Deserialize, Clone)]
|
||||||
|
|
|
@ -380,7 +380,7 @@ impl<'a> CommentQueryBuilder<'a> {
|
||||||
SortType::Hot | SortType::Active => query
|
SortType::Hot | SortType::Active => query
|
||||||
.order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
|
.order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
|
||||||
.then_order_by(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::TopAll => query.order_by(comment_aggregates::score.desc()),
|
||||||
SortType::TopYear => query
|
SortType::TopYear => query
|
||||||
.filter(comment::published.gt(now - 1.years()))
|
.filter(comment::published.gt(now - 1.years()))
|
||||||
|
|
|
@ -363,6 +363,7 @@ impl<'a> PostQueryBuilder<'a> {
|
||||||
.then_order_by(hot_rank(post_aggregates::score, post_aggregates::published).desc())
|
.then_order_by(hot_rank(post_aggregates::score, post_aggregates::published).desc())
|
||||||
.then_order_by(post_aggregates::published.desc()),
|
.then_order_by(post_aggregates::published.desc()),
|
||||||
SortType::New => query.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::TopAll => query.then_order_by(post_aggregates::score.desc()),
|
||||||
SortType::TopYear => query
|
SortType::TopYear => query
|
||||||
.filter(post::published.gt(now - 1.years()))
|
.filter(post::published.gt(now - 1.years()))
|
||||||
|
|
|
@ -270,7 +270,7 @@ impl<'a> UserMentionQueryBuilder<'a> {
|
||||||
SortType::Hot | SortType::Active => query
|
SortType::Hot | SortType::Active => query
|
||||||
.order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
|
.order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
|
||||||
.then_order_by(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::TopAll => query.order_by(comment_aggregates::score.desc()),
|
||||||
SortType::TopYear => query
|
SortType::TopYear => query
|
||||||
.filter(comment::published.gt(now - 1.years()))
|
.filter(comment::published.gt(now - 1.years()))
|
||||||
|
|
|
@ -110,7 +110,7 @@ impl<'a> UserQueryBuilder<'a> {
|
||||||
SortType::Active => query
|
SortType::Active => query
|
||||||
.order_by(user_aggregates::comment_score.desc())
|
.order_by(user_aggregates::comment_score.desc())
|
||||||
.then_order_by(user_::published.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::TopAll => query.order_by(user_aggregates::comment_score.desc()),
|
||||||
SortType::TopYear => query
|
SortType::TopYear => query
|
||||||
.filter(user_::published.gt(now - 1.years()))
|
.filter(user_::published.gt(now - 1.years()))
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
drop index idx_post_aggregates_comments;
|
1
migrations/2021-01-31-050334_add_forum_sort_index/up.sql
Normal file
1
migrations/2021-01-31-050334_add_forum_sort_index/up.sql
Normal file
|
@ -0,0 +1 @@
|
||||||
|
create index idx_post_aggregates_comments on post_aggregates (comments desc);
|
Loading…
Reference in a new issue