]> Untitled Git - lemmy.git/commitdiff
Remove unused db view options (#3787)
authorNutomic <me@nutomic.com>
Fri, 4 Aug 2023 15:36:36 +0000 (17:36 +0200)
committerGitHub <noreply@github.com>
Fri, 4 Aug 2023 15:36:36 +0000 (11:36 -0400)
* Remove unused db view options

* fix tests

* ci

crates/apub/src/api/read_person.rs
crates/db_views/src/comment_view.rs
crates/db_views/src/post_view.rs

index 5d3c73c30bee970198b92fe582927676a2dfbc72..e5924dc82eea5b3901621d865067e49980ae9da6 100644 (file)
@@ -65,7 +65,7 @@ pub async fn read_person(
     saved_only,
     local_user: local_user_view.as_ref(),
     community_id,
-    is_profile_view: Some(true),
+    is_profile_view: true,
     page,
     limit,
     creator_id,
@@ -75,14 +75,13 @@ pub async fn read_person(
   .await?;
 
   let comments = CommentQuery {
-    local_user: (local_user_view.as_ref()),
-    sort: (sort.map(post_to_comment_sort_type)),
-    saved_only: (saved_only),
-    show_deleted_and_removed: (Some(false)),
-    community_id: (community_id),
-    is_profile_view: Some(true),
-    page: (page),
-    limit: (limit),
+    local_user: local_user_view.as_ref(),
+    sort: sort.map(post_to_comment_sort_type),
+    saved_only,
+    community_id,
+    is_profile_view: true,
+    page,
+    limit,
     creator_id,
     ..Default::default()
   }
index 26787cceb4c8992132bd29941d1b7c07e56b0910..4cad1e74528238548ae34fe17c306b0e4021d461 100644 (file)
@@ -195,7 +195,6 @@ fn queries<'a>() -> Queries<
       query = query.filter(comment_saved::comment_id.is_not_null());
     }
 
-    let is_profile_view = options.is_profile_view.unwrap_or(false);
     let is_creator = options.creator_id == options.local_user.map(|l| l.person.id);
     // only show deleted comments to creator
     if !is_creator {
@@ -204,7 +203,7 @@ fn queries<'a>() -> Queries<
 
     let is_admin = options.local_user.map(|l| l.person.admin).unwrap_or(false);
     // only show removed comments to admin when viewing user profile
-    if !(is_profile_view && is_admin) {
+    if !(options.is_profile_view && is_admin) {
       query = query.filter(comment::removed.eq(false));
     }
 
@@ -310,8 +309,7 @@ pub struct CommentQuery<'a> {
   pub local_user: Option<&'a LocalUserView>,
   pub search_term: Option<String>,
   pub saved_only: Option<bool>,
-  pub is_profile_view: Option<bool>,
-  pub show_deleted_and_removed: Option<bool>,
+  pub is_profile_view: bool,
   pub page: Option<i64>,
   pub limit: Option<i64>,
   pub max_depth: Option<i32>,
index 3243bca882dae9a08e05bb4f6f56ab09393d24e2..30de18b694b8e533d59f3de7ba4f67ca561b464c 100644 (file)
@@ -212,7 +212,6 @@ fn queries<'a>() -> Queries<
       )
       .select(selection);
 
-    let is_profile_view = options.is_profile_view.unwrap_or(false);
     let is_creator = options.creator_id == options.local_user.map(|l| l.person.id);
     // only show deleted posts to creator
     if is_creator {
@@ -223,7 +222,7 @@ fn queries<'a>() -> Queries<
 
     let is_admin = options.local_user.map(|l| l.person.admin).unwrap_or(false);
     // only show removed posts to admin when viewing user profile
-    if !(is_profile_view && is_admin) {
+    if !(options.is_profile_view && is_admin) {
       query = query
         .filter(community::removed.eq(false))
         .filter(post::removed.eq(false));
@@ -428,7 +427,7 @@ pub struct PostQuery<'a> {
   pub url_search: Option<String>,
   pub saved_only: Option<bool>,
   pub moderator_view: Option<bool>,
-  pub is_profile_view: Option<bool>,
+  pub is_profile_view: bool,
   pub page: Option<i64>,
   pub limit: Option<i64>,
 }
@@ -919,7 +918,7 @@ mod tests {
     let post_listings_is_admin = PostQuery {
       sort: Some(SortType::New),
       local_user: Some(&data.local_user_view),
-      is_profile_view: Some(true),
+      is_profile_view: true,
       ..Default::default()
     }
     .list(pool)