do rename everywhere else

This commit is contained in:
Dull Bananas 2024-12-26 22:07:44 -07:00
parent 5f72a5b23f
commit c75b5f93df
7 changed files with 39 additions and 40 deletions

View file

@ -273,7 +273,7 @@ fn queries<'a>() -> Queries<
// (i64::MAX, 0)
(300, 0)
} else {
// limit_and_offset_unlimited(options.page, options.limit)
// limit_and_offset_unlimited(o.page, o.limit)
limit_and_offset(o.page, o.limit)?
};

View file

@ -53,8 +53,7 @@ fn queries<'a>() -> Queries<
.await
};
let list = move |mut conn: DbConn<'a>,
(options, recipient_id): (PrivateMessageQuery, PersonId)| async move {
let list = move |mut conn: DbConn<'a>, (o, recipient_id): (PrivateMessageQuery, PersonId)| async move {
let mut query = all_joins(private_message::table.into_boxed())
.select(selection)
// Dont show replies from blocked users
@ -63,9 +62,9 @@ fn queries<'a>() -> Queries<
.filter(instance_actions::blocked.is_null());
// If its unread, I only want the ones to me
if options.unread_only {
if o.unread_only {
query = query.filter(private_message::read.eq(false));
if let Some(i) = options.creator_id {
if let Some(i) = o.creator_id {
query = query.filter(private_message::creator_id.eq(i))
}
query = query.filter(private_message::recipient_id.eq(recipient_id));
@ -77,7 +76,7 @@ fn queries<'a>() -> Queries<
.eq(recipient_id)
.or(private_message::creator_id.eq(recipient_id)),
);
if let Some(i) = options.creator_id {
if let Some(i) = o.creator_id {
query = query.filter(
private_message::creator_id
.eq(i)
@ -86,7 +85,7 @@ fn queries<'a>() -> Queries<
}
}
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
let (limit, offset) = limit_and_offset(o.page, o.limit)?;
query = query
.filter(private_message::deleted.eq(false))

View file

@ -53,12 +53,12 @@ fn queries<'a>() -> Queries<
query.first(&mut conn).await
};
let list = move |mut conn: DbConn<'a>, options: RegistrationApplicationQuery| async move {
let list = move |mut conn: DbConn<'a>, o: RegistrationApplicationQuery| async move {
let mut query = all_joins(registration_application::table.into_boxed());
// If viewing all applications, order by newest, but if viewing unresolved only, show the oldest
// first (FIFO)
if options.unread_only {
if o.unread_only {
query = query
.filter(registration_application::admin_id.is_null())
.order_by(registration_application::published.asc());
@ -66,11 +66,11 @@ fn queries<'a>() -> Queries<
query = query.order_by(registration_application::published.desc());
}
if options.verified_email_only {
if o.verified_email_only {
query = query.filter(local_user::email_verified.eq(true))
}
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
let (limit, offset) = limit_and_offset(o.page, o.limit)?;
query = query.limit(limit).offset(offset);

View file

@ -113,24 +113,24 @@ fn queries<'a>() -> Queries<
.await
};
let list = move |mut conn: DbConn<'a>, options: CommentReplyQuery| async move {
let list = move |mut conn: DbConn<'a>, o: CommentReplyQuery| async move {
// These filters need to be kept in sync with the filters in
// CommentReplyView::get_unread_replies()
let mut query = all_joins(comment_reply::table.into_boxed(), options.my_person_id);
let mut query = all_joins(comment_reply::table.into_boxed(), o.my_person_id);
if let Some(recipient_id) = options.recipient_id {
if let Some(recipient_id) = o.recipient_id {
query = query.filter(comment_reply::recipient_id.eq(recipient_id));
}
if options.unread_only {
if o.unread_only {
query = query.filter(comment_reply::read.eq(false));
}
if !options.show_bot_accounts {
if !o.show_bot_accounts {
query = query.filter(not(person::bot_account));
};
query = match options.sort.unwrap_or(CommentSortType::New) {
query = match o.sort.unwrap_or(CommentSortType::New) {
CommentSortType::Hot => query.then_order_by(comment_aggregates::hot_rank.desc()),
CommentSortType::Controversial => {
query.then_order_by(comment_aggregates::controversy_rank.desc())
@ -143,7 +143,7 @@ fn queries<'a>() -> Queries<
// Don't show replies from blocked persons
query = query.filter(person_actions::blocked.is_null());
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
let (limit, offset) = limit_and_offset(o.page, o.limit)?;
query
.limit(limit)

View file

@ -90,17 +90,17 @@ fn queries<'a>() -> Queries<
query.first(&mut conn).await
};
let list = move |mut conn: DbConn<'a>, (options, site): (CommunityQuery<'a>, &'a Site)| async move {
let list = move |mut conn: DbConn<'a>, (o, site): (CommunityQuery<'a>, &'a Site)| async move {
use CommunitySortType::*;
let mut query = all_joins(community::table.into_boxed(), options.local_user).select(selection);
let mut query = all_joins(community::table.into_boxed(), o.local_user).select(selection);
if let Some(search_term) = options.search_term {
if let Some(search_term) = o.search_term {
let searcher = fuzzy_search(&search_term);
let name_filter = community::name.ilike(searcher.clone());
let title_filter = community::title.ilike(searcher.clone());
let description_filter = community::description.ilike(searcher.clone());
query = if options.title_only.unwrap_or_default() {
query = if o.title_only.unwrap_or_default() {
query.filter(name_filter.or(title_filter))
} else {
query.filter(name_filter.or(title_filter.or(description_filter)))
@ -108,7 +108,7 @@ fn queries<'a>() -> Queries<
}
// Hide deleted and removed for non-admins or mods
if !options.is_mod_or_admin {
if !o.is_mod_or_admin {
query = query.filter(not_removed_or_deleted).filter(
community::hidden
.eq(false)
@ -116,7 +116,7 @@ fn queries<'a>() -> Queries<
);
}
match options.sort.unwrap_or(Hot) {
match o.sort.unwrap_or(Hot) {
Hot | Active | Scaled => query = query.order_by(community_aggregates::hot_rank.desc()),
NewComments | TopDay | TopTwelveHour | TopSixHour | TopHour => {
query = query.order_by(community_aggregates::users_active_day.desc())
@ -137,7 +137,7 @@ fn queries<'a>() -> Queries<
NameDesc => query = query.order_by(lower(community::name).desc()),
};
if let Some(listing_type) = options.listing_type {
if let Some(listing_type) = o.listing_type {
query = match listing_type {
ListingType::Subscribed => {
query.filter(community_actions::follow_state.eq(Some(CommunityFollowerState::Accepted)))
@ -151,13 +151,13 @@ fn queries<'a>() -> Queries<
// also hidden (based on profile setting)
query = query.filter(instance_actions::blocked.is_null());
query = query.filter(community_actions::blocked.is_null());
if !(options.local_user.show_nsfw(site) || options.show_nsfw) {
if !(o.local_user.show_nsfw(site) || o.show_nsfw) {
query = query.filter(community::nsfw.eq(false));
}
query = options.local_user.visible_communities_only(query);
query = o.local_user.visible_communities_only(query);
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
let (limit, offset) = limit_and_offset(o.page, o.limit)?;
query
.limit(limit)
.offset(offset)

View file

@ -113,24 +113,24 @@ fn queries<'a>() -> Queries<
.await
};
let list = move |mut conn: DbConn<'a>, options: PersonMentionQuery| async move {
let list = move |mut conn: DbConn<'a>, o: PersonMentionQuery| async move {
// These filters need to be kept in sync with the filters in
// PersonMentionView::get_unread_mentions()
let mut query = all_joins(person_mention::table.into_boxed(), options.my_person_id);
let mut query = all_joins(person_mention::table.into_boxed(), o.my_person_id);
if let Some(recipient_id) = options.recipient_id {
if let Some(recipient_id) = o.recipient_id {
query = query.filter(person_mention::recipient_id.eq(recipient_id));
}
if options.unread_only {
if o.unread_only {
query = query.filter(person_mention::read.eq(false));
}
if !options.show_bot_accounts {
if !o.show_bot_accounts {
query = query.filter(not(person::bot_account));
};
query = match options.sort.unwrap_or(CommentSortType::Hot) {
query = match o.sort.unwrap_or(CommentSortType::Hot) {
CommentSortType::Hot => query.then_order_by(comment_aggregates::hot_rank.desc()),
CommentSortType::Controversial => {
query.then_order_by(comment_aggregates::controversy_rank.desc())
@ -143,7 +143,7 @@ fn queries<'a>() -> Queries<
// Don't show mentions from blocked persons
query = query.filter(person_actions::blocked.is_null());
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
let (limit, offset) = limit_and_offset(o.page, o.limit)?;
query
.limit(limit)

View file

@ -99,15 +99,15 @@ fn queries<'a>(
)
.filter(person::deleted.eq(false));
}
ListMode::Query(options) => {
if let Some(search_term) = options.search_term {
ListMode::Query(oo) => {
if let Some(search_term) = o.search_term {
let searcher = fuzzy_search(&search_term);
query = query
.filter(person::name.ilike(searcher.clone()))
.or_filter(person::display_name.ilike(searcher));
}
let sort = options.sort.map(post_to_person_sort_type);
let sort = o.sort.map(post_to_person_sort_type);
query = match sort.unwrap_or(PersonSortType::CommentScore) {
PersonSortType::New => query.order_by(person::published.desc()),
PersonSortType::Old => query.order_by(person::published.asc()),
@ -117,10 +117,10 @@ fn queries<'a>(
PersonSortType::PostCount => query.order_by(person_aggregates::post_count.desc()),
};
let (limit, offset) = limit_and_offset(options.page, options.limit)?;
let (limit, offset) = limit_and_offset(o.page, o.limit)?;
query = query.limit(limit).offset(offset);
if let Some(listing_type) = options.listing_type {
if let Some(listing_type) = o.listing_type {
query = match listing_type {
// return nothing as its not possible to follow users
ListingType::Subscribed => query.limit(0),