use crate::structs::CommentReplyView;
use diesel::{
- dsl::now,
result::Error,
BoolExpressionMethods,
ExpressionMethods,
community_person_ban::table.on(
community::id
.eq(community_person_ban::community_id)
- .and(community_person_ban::person_id.eq(comment::creator_id))
- .and(
- community_person_ban::expires
- .is_null()
- .or(community_person_ban::expires.gt(now)),
- ),
+ .and(community_person_ban::person_id.eq(comment::creator_id)),
),
)
.left_join(
community_person_ban::table.on(
community::id
.eq(community_person_ban::community_id)
- .and(community_person_ban::person_id.eq(comment::creator_id))
- .and(
- community_person_ban::expires
- .is_null()
- .or(community_person_ban::expires.gt(now)),
- ),
+ .and(community_person_ban::person_id.eq(comment::creator_id)),
),
)
.left_join(
query = query.filter(person::bot_account.eq(false));
};
- query = match self.sort.unwrap_or(CommentSortType::Hot) {
+ query = match self.sort.unwrap_or(CommentSortType::New) {
CommentSortType::Hot => query
.then_order_by(hot_rank(comment_aggregates::score, comment_aggregates::published).desc())
.then_order_by(comment_aggregates::published.desc()),
- CommentSortType::New => query.then_order_by(comment::published.desc()),
- CommentSortType::Old => query.then_order_by(comment::published.asc()),
+ CommentSortType::New => query.then_order_by(comment_reply::published.desc()),
+ CommentSortType::Old => query.then_order_by(comment_reply::published.asc()),
CommentSortType::Top => query.order_by(comment_aggregates::score.desc()),
};