From 6b40083504e2dd1e506488d81eb0114dde36cacd Mon Sep 17 00:00:00 2001 From: Dull Bananas Date: Mon, 23 Dec 2024 16:01:28 -0700 Subject: [PATCH 1/3] comment view, post view --- crates/db_views/src/comment_view.rs | 53 +++++++++----------- crates/db_views/src/post_view.rs | 75 +++++++++++++---------------- 2 files changed, 57 insertions(+), 71 deletions(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 2cf751f9f2..8b50cbf9f9 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -141,28 +141,25 @@ fn queries<'a>() -> Queries< query.first(&mut conn).await }; - let list = move |mut conn: DbConn<'a>, (options, site): (CommentQuery<'a>, &'a Site)| async move { + let list = move |mut conn: DbConn<'a>, (o, site): (CommentQuery<'a>, &'a Site)| async move { // The left join below will return None in this case - let local_user_id_join = options - .local_user - .local_user_id() - .unwrap_or(LocalUserId(-1)); + let local_user_id_join = o.local_user.local_user_id().unwrap_or(LocalUserId(-1)); - let mut query = all_joins(comment::table.into_boxed(), options.local_user.person_id()); + let mut query = all_joins(comment::table.into_boxed(), o.local_user.person_id()); - if let Some(creator_id) = options.creator_id { + if let Some(creator_id) = o.creator_id { query = query.filter(comment::creator_id.eq(creator_id)); }; - if let Some(post_id) = options.post_id { + if let Some(post_id) = o.post_id { query = query.filter(comment::post_id.eq(post_id)); }; - if let Some(parent_path) = options.parent_path.as_ref() { + if let Some(parent_path) = o.parent_path.as_ref() { query = query.filter(comment::path.contained_by(parent_path)); }; //filtering out removed and deleted comments from search - if let Some(search_term) = options.search_term { + if let Some(search_term) = o.search_term { query = query.filter( comment::content .ilike(fuzzy_search(&search_term)) @@ -170,13 +167,13 @@ fn queries<'a>() -> Queries< ); }; - if let Some(community_id) = options.community_id { + if let Some(community_id) = o.community_id { query = query.filter(post::community_id.eq(community_id)); } let is_subscribed = community_actions::followed.is_not_null(); - match options.listing_type.unwrap_or_default() { + match o.listing_type.unwrap_or_default() { ListingType::Subscribed => query = query.filter(is_subscribed), /* TODO could be this: and(community_follower::person_id.eq(person_id_join)), */ ListingType::Local => { query = query @@ -190,32 +187,30 @@ fn queries<'a>() -> Queries< } // If its saved only, then filter, and order by the saved time, not the comment creation time. - if options.saved_only.unwrap_or_default() { + if o.saved_only.unwrap_or_default() { query = query .filter(comment_actions::saved.is_not_null()) .then_order_by(comment_actions::saved.desc()); } - if let Some(my_id) = options.local_user.person_id() { + if let Some(my_id) = o.local_user.person_id() { let not_creator_filter = comment::creator_id.ne(my_id); - if options.liked_only.unwrap_or_default() { + if o.liked_only.unwrap_or_default() { query = query .filter(not_creator_filter) .filter(comment_actions::like_score.eq(1)); - } else if options.disliked_only.unwrap_or_default() { + } else if o.disliked_only.unwrap_or_default() { query = query .filter(not_creator_filter) .filter(comment_actions::like_score.eq(-1)); } } - if !options.local_user.show_bot_accounts() { + if !o.local_user.show_bot_accounts() { query = query.filter(person::bot_account.eq(false)); }; - if options.local_user.is_some() - && options.listing_type.unwrap_or_default() != ListingType::ModeratorView - { + if o.local_user.is_some() && o.listing_type.unwrap_or_default() != ListingType::ModeratorView { // Filter out the rows with missing languages query = query.filter(exists( local_user_language::table.filter( @@ -232,15 +227,15 @@ fn queries<'a>() -> Queries< .filter(person_actions::blocked.is_null()); }; - if !options.local_user.show_nsfw(site) { + if !o.local_user.show_nsfw(site) { query = query .filter(post::nsfw.eq(false)) .filter(community::nsfw.eq(false)); }; - query = options.local_user.visible_communities_only(query); + query = o.local_user.visible_communities_only(query); - if !options.local_user.is_admin() { + if !o.local_user.is_admin() { query = query.filter( community::visibility .ne(CommunityVisibility::Private) @@ -249,8 +244,8 @@ fn queries<'a>() -> Queries< } // A Max depth given means its a tree fetch - let (limit, offset) = if let Some(max_depth) = options.max_depth { - let depth_limit = if let Some(parent_path) = options.parent_path.as_ref() { + let (limit, offset) = if let Some(max_depth) = o.max_depth { + let depth_limit = if let Some(parent_path) = o.parent_path.as_ref() { parent_path.0.split('.').count() as i32 + max_depth // Add one because of root "0" } else { @@ -261,7 +256,7 @@ fn queries<'a>() -> Queries< // only order if filtering by a post id, or parent_path. DOS potential otherwise and max_depth // + !post_id isn't used anyways (afaik) - if options.post_id.is_some() || options.parent_path.is_some() { + if o.post_id.is_some() || o.parent_path.is_some() { // Always order by the parent path first query = query.then_order_by(subpath(comment::path, 0, -1)); } @@ -279,15 +274,15 @@ fn queries<'a>() -> Queries< (300, 0) } else { // limit_and_offset_unlimited(options.page, options.limit) - limit_and_offset(options.page, options.limit)? + limit_and_offset(o.page, o.limit)? }; // distinguished comments should go first when viewing post - if options.post_id.is_some() || options.parent_path.is_some() { + if o.post_id.is_some() || o.parent_path.is_some() { query = query.then_order_by(comment::distinguished.desc()); } - 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()) .then_order_by(comment_aggregates::score.desc()), diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 6ed89e3643..741df57ff0 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -226,23 +226,20 @@ fn queries<'a>() -> Queries< .await }; - let list = move |mut conn: DbConn<'a>, (options, site): (PostQuery<'a>, &'a Site)| async move { + let list = move |mut conn: DbConn<'a>, (o, site): (PostQuery<'a>, &'a Site)| async move { // The left join below will return None in this case - let local_user_id_join = options - .local_user - .local_user_id() - .unwrap_or(LocalUserId(-1)); + let local_user_id_join = o.local_user.local_user_id().unwrap_or(LocalUserId(-1)); let mut query = all_joins( post_aggregates::table.into_boxed(), - options.local_user.person_id(), + o.local_user.person_id(), ); // hide posts from deleted communities query = query.filter(community::deleted.eq(false)); // only creator can see deleted posts and unpublished scheduled posts - if let Some(person_id) = options.local_user.person_id() { + if let Some(person_id) = o.local_user.person_id() { query = query.filter(post::deleted.eq(false).or(post::creator_id.eq(person_id))); query = query.filter( post::scheduled_publish_time @@ -256,21 +253,21 @@ fn queries<'a>() -> Queries< } // only show removed posts to admin when viewing user profile - if !(options.creator_id.is_some() && options.local_user.is_admin()) { + if !(o.creator_id.is_some() && o.local_user.is_admin()) { query = query .filter(community::removed.eq(false)) .filter(post::removed.eq(false)); } - if let Some(community_id) = options.community_id { + if let Some(community_id) = o.community_id { query = query.filter(post_aggregates::community_id.eq(community_id)); } - if let Some(creator_id) = options.creator_id { + if let Some(creator_id) = o.creator_id { query = query.filter(post_aggregates::creator_id.eq(creator_id)); } let is_subscribed = community_actions::followed.is_not_null(); - match options.listing_type.unwrap_or_default() { + match o.listing_type.unwrap_or_default() { ListingType::Subscribed => query = query.filter(is_subscribed), ListingType::Local => { query = query @@ -283,14 +280,14 @@ fn queries<'a>() -> Queries< } } - if let Some(search_term) = &options.search_term { - if options.url_only.unwrap_or_default() { + if let Some(search_term) = &o.search_term { + if o.url_only.unwrap_or_default() { query = query.filter(post::url.eq(search_term)); } else { let searcher = fuzzy_search(search_term); let name_filter = post::name.ilike(searcher.clone()); let body_filter = post::body.ilike(searcher.clone()); - query = if options.title_only.unwrap_or_default() { + query = if o.title_only.unwrap_or_default() { query.filter(name_filter) } else { query.filter(name_filter.or(body_filter)) @@ -299,64 +296,58 @@ fn queries<'a>() -> Queries< } } - if !options - .show_nsfw - .unwrap_or(options.local_user.show_nsfw(site)) - { + if !o.show_nsfw.unwrap_or(o.local_user.show_nsfw(site)) { query = query .filter(post::nsfw.eq(false)) .filter(community::nsfw.eq(false)); }; - if !options.local_user.show_bot_accounts() { + if !o.local_user.show_bot_accounts() { query = query.filter(person::bot_account.eq(false)); }; // Filter to show only posts with no comments - if options.no_comments_only.unwrap_or_default() { + if o.no_comments_only.unwrap_or_default() { query = query.filter(post_aggregates::comments.eq(0)); }; // If its saved only, then filter, and order by the saved time, not the comment creation time. - if options.saved_only.unwrap_or_default() { + if o.saved_only.unwrap_or_default() { query = query .filter(post_actions::saved.is_not_null()) .then_order_by(post_actions::saved.desc()); } // Only hide the read posts, if the saved_only is false. Otherwise ppl with the hide_read // setting wont be able to see saved posts. - else if !options - .show_read - .unwrap_or(options.local_user.show_read_posts()) - { + else if !o.show_read.unwrap_or(o.local_user.show_read_posts()) { // Do not hide read posts when it is a user profile view // Or, only hide read posts on non-profile views - if options.creator_id.is_none() { + if o.creator_id.is_none() { query = query.filter(post_actions::read.is_null()); } } // If a creator id isn't given (IE its on home or community pages), hide the hidden posts - if !options.show_hidden.unwrap_or_default() && options.creator_id.is_none() { + if !o.show_hidden.unwrap_or_default() && o.creator_id.is_none() { query = query.filter(post_actions::hidden.is_null()); } - if let Some(my_id) = options.local_user.person_id() { + if let Some(my_id) = o.local_user.person_id() { let not_creator_filter = post_aggregates::creator_id.ne(my_id); - if options.liked_only.unwrap_or_default() { + if o.liked_only.unwrap_or_default() { query = query .filter(not_creator_filter) .filter(post_actions::like_score.eq(1)); - } else if options.disliked_only.unwrap_or_default() { + } else if o.disliked_only.unwrap_or_default() { query = query .filter(not_creator_filter) .filter(post_actions::like_score.eq(-1)); } }; - query = options.local_user.visible_communities_only(query); + query = o.local_user.visible_communities_only(query); - if !options.local_user.is_admin() { + if !o.local_user.is_admin() { query = query.filter( community::visibility .ne(CommunityVisibility::Private) @@ -365,9 +356,9 @@ fn queries<'a>() -> Queries< } // Dont filter blocks or missing languages for moderator view type - if options.listing_type.unwrap_or_default() != ListingType::ModeratorView { + if o.listing_type.unwrap_or_default() != ListingType::ModeratorView { // Filter out the rows with missing languages if user is logged in - if options.local_user.is_some() { + if o.local_user.is_some() { query = query.filter(exists( local_user_language::table.filter( post::language_id @@ -383,15 +374,15 @@ fn queries<'a>() -> Queries< 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 = query.limit(limit).offset(offset); let mut query = PaginatedQueryBuilder::new(query); - let page_after = options.page_after.map(|c| c.0); - let page_before_or_equal = options.page_before_or_equal.map(|c| c.0); + let page_after = o.page_after.map(|c| c.0); + let page_before_or_equal = o.page_before_or_equal.map(|c| c.0); - if options.page_back.unwrap_or_default() { + if o.page_back.unwrap_or_default() { query = query .before(page_after) .after_or_equal(page_before_or_equal) @@ -403,7 +394,7 @@ fn queries<'a>() -> Queries< } // featured posts first - query = if options.community_id.is_none() || options.community_id_just_for_prefetch { + query = if o.community_id.is_none() || o.community_id_just_for_prefetch { query.then_desc(key::featured_local) } else { query.then_desc(key::featured_community) @@ -412,7 +403,7 @@ fn queries<'a>() -> Queries< let time = |interval| post_aggregates::published.gt(now() - interval); // then use the main sort - query = match options.sort.unwrap_or(Hot) { + query = match o.sort.unwrap_or(Hot) { Active => query.then_desc(key::hot_rank_active), Hot => query.then_desc(key::hot_rank), Scaled => query.then_desc(key::scaled_rank), @@ -436,7 +427,7 @@ fn queries<'a>() -> Queries< // use publish as fallback. especially useful for hot rank which reaches zero after some days. // necessary because old posts can be fetched over federation and inserted with high post id - query = match options.sort.unwrap_or(Hot) { + query = match o.sort.unwrap_or(Hot) { // A second time-based sort would not be very useful New | Old | NewComments => query, _ => query.then_desc(key::published), @@ -454,7 +445,7 @@ fn queries<'a>() -> Queries< .text("PostQuery::list") .text_if( "getting upper bound for next query", - options.community_id_just_for_prefetch, + o.community_id_just_for_prefetch, ) .load::(&mut conn) .await From c75b5f93df1655d9e19c60dfdc3b72a4571fb2b9 Mon Sep 17 00:00:00 2001 From: Dull Bananas Date: Thu, 26 Dec 2024 22:07:44 -0700 Subject: [PATCH 2/3] do rename everywhere else --- crates/db_views/src/comment_view.rs | 2 +- crates/db_views/src/private_message_view.rs | 11 +++++----- .../src/registration_application_view.rs | 8 ++++---- .../db_views_actor/src/comment_reply_view.rs | 14 ++++++------- crates/db_views_actor/src/community_view.rs | 20 +++++++++---------- .../db_views_actor/src/person_mention_view.rs | 14 ++++++------- crates/db_views_actor/src/person_view.rs | 10 +++++----- 7 files changed, 39 insertions(+), 40 deletions(-) diff --git a/crates/db_views/src/comment_view.rs b/crates/db_views/src/comment_view.rs index 8b50cbf9f9..504f3cc4e0 100644 --- a/crates/db_views/src/comment_view.rs +++ b/crates/db_views/src/comment_view.rs @@ -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)? }; diff --git a/crates/db_views/src/private_message_view.rs b/crates/db_views/src/private_message_view.rs index 2286b7dc67..346dab49a9 100644 --- a/crates/db_views/src/private_message_view.rs +++ b/crates/db_views/src/private_message_view.rs @@ -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)) diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index 0fa0a5d7e5..72329b9783 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -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); diff --git a/crates/db_views_actor/src/comment_reply_view.rs b/crates/db_views_actor/src/comment_reply_view.rs index 6c5442e6af..75f8ed4e2e 100644 --- a/crates/db_views_actor/src/comment_reply_view.rs +++ b/crates/db_views_actor/src/comment_reply_view.rs @@ -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) diff --git a/crates/db_views_actor/src/community_view.rs b/crates/db_views_actor/src/community_view.rs index 8bcf50ba39..1a8e3c4cd7 100644 --- a/crates/db_views_actor/src/community_view.rs +++ b/crates/db_views_actor/src/community_view.rs @@ -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) diff --git a/crates/db_views_actor/src/person_mention_view.rs b/crates/db_views_actor/src/person_mention_view.rs index 08be67a826..b3d6235d44 100644 --- a/crates/db_views_actor/src/person_mention_view.rs +++ b/crates/db_views_actor/src/person_mention_view.rs @@ -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) diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views_actor/src/person_view.rs index b90ab78115..98ee122ed9 100644 --- a/crates/db_views_actor/src/person_view.rs +++ b/crates/db_views_actor/src/person_view.rs @@ -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), From 0328e3878da69984ac955ce6cd7f8492c81d39b1 Mon Sep 17 00:00:00 2001 From: Dull Bananas Date: Fri, 27 Dec 2024 16:30:18 -0700 Subject: [PATCH 3/3] fix person_view --- crates/db_views_actor/src/person_view.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/db_views_actor/src/person_view.rs b/crates/db_views_actor/src/person_view.rs index 98ee122ed9..bc12e6559d 100644 --- a/crates/db_views_actor/src/person_view.rs +++ b/crates/db_views_actor/src/person_view.rs @@ -99,7 +99,7 @@ fn queries<'a>( ) .filter(person::deleted.eq(false)); } - ListMode::Query(oo) => { + ListMode::Query(o) => { if let Some(search_term) = o.search_term { let searcher = fuzzy_search(&search_term); query = query