- match self.sort.unwrap_or(SortType::Hot) {
- SortType::New => query = query.order_by(community::published.desc()),
- SortType::TopAll => query = query.order_by(community_aggregates::subscribers.desc()),
- SortType::TopMonth => query = query.order_by(community_aggregates::users_active_month.desc()),
- SortType::Hot => {
- query = query.order_by(community_aggregates::users_active_month.desc());
- // Don't show hidden communities in Hot (trending)
- query = query.filter(
- community::hidden
- .eq(false)
- .or(community_follower::person_id.eq(person_id_join)),
- );
+ // Hide deleted and removed for non-admins or mods
+ if !options.is_mod_or_admin {
+ query = query.filter(not_removed_or_deleted).filter(
+ community::hidden
+ .eq(false)
+ .or(community_follower::person_id.eq(person_id_join)),
+ );
+ }
+
+ match options.sort.unwrap_or(Hot) {
+ Hot | Active => query = query.order_by(community_aggregates::hot_rank.desc()),
+ NewComments | TopDay | TopTwelveHour | TopSixHour | TopHour => {
+ query = query.order_by(community_aggregates::users_active_day.desc())
+ }
+ New => query = query.order_by(community::published.desc()),
+ Old => query = query.order_by(community::published.asc()),
+ // Controversial is temporary until a CommentSortType is created
+ MostComments | Controversial => query = query.order_by(community_aggregates::comments.desc()),
+ TopAll | TopYear | TopNineMonths => {
+ query = query.order_by(community_aggregates::subscribers.desc())