Sort community search by active_monthly by default. (#2728)

- Fixes #2678
This commit is contained in:
Dessalines 2023-02-14 09:19:37 -05:00 committed by GitHub
parent 3bb98fcc64
commit 166854b37e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 22 deletions

View file

@ -128,7 +128,7 @@ pub(crate) async fn get_activity(
let sensitive = activity.sensitive.unwrap_or(true); let sensitive = activity.sensitive.unwrap_or(true);
if !activity.local { if !activity.local {
return Err(err_object_not_local()); Err(err_object_not_local())
} else if sensitive { } else if sensitive {
Ok(HttpResponse::Forbidden().finish()) Ok(HttpResponse::Forbidden().finish())
} else { } else {

View file

@ -19,7 +19,7 @@ use lemmy_db_schema::{
local_user::LocalUser, local_user::LocalUser,
}, },
traits::{ToSafe, ViewToVec}, traits::{ToSafe, ViewToVec},
utils::{functions::hot_rank, fuzzy_search, get_conn, limit_and_offset, DbPool}, utils::{fuzzy_search, get_conn, limit_and_offset, DbPool},
ListingType, ListingType,
SortType, SortType,
}; };
@ -164,15 +164,7 @@ impl<'a> CommunityQuery<'a> {
SortType::TopAll => query = query.order_by(community_aggregates::subscribers.desc()), SortType::TopAll => query = query.order_by(community_aggregates::subscribers.desc()),
SortType::TopMonth => query = query.order_by(community_aggregates::users_active_month.desc()), SortType::TopMonth => query = query.order_by(community_aggregates::users_active_month.desc()),
SortType::Hot => { SortType::Hot => {
query = query query = query.order_by(community_aggregates::users_active_month.desc());
.order_by(
hot_rank(
community_aggregates::subscribers,
community_aggregates::published,
)
.desc(),
)
.then_order_by(community_aggregates::published.desc());
// Don't show hidden communities in Hot (trending) // Don't show hidden communities in Hot (trending)
query = query.filter( query = query.filter(
community::hidden community::hidden
@ -181,17 +173,7 @@ impl<'a> CommunityQuery<'a> {
); );
} }
// Covers all other sorts // Covers all other sorts
_ => { _ => query = query.order_by(community_aggregates::users_active_month.desc()),
query = query
.order_by(
hot_rank(
community_aggregates::subscribers,
community_aggregates::published,
)
.desc(),
)
.then_order_by(community_aggregates::published.desc())
}
}; };
if let Some(listing_type) = self.listing_type { if let Some(listing_type) = self.listing_type {