]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/impls/post.rs
Implement separate mod activities for feature, lock post (#2716)
[lemmy.git] / crates / db_schema / src / impls / post.rs
index 91e7bc1e316e5456a36887afd5e86dec42ee32da..9f5c64389b5f735343bbd932ce766cf7e3599d7c 100644 (file)
@@ -89,6 +89,22 @@ impl Post {
       .await
   }
 
+  pub async fn list_featured_for_community(
+    pool: &DbPool,
+    the_community_id: CommunityId,
+  ) -> Result<Vec<Self>, Error> {
+    let conn = &mut get_conn(pool).await?;
+    post
+      .filter(community_id.eq(the_community_id))
+      .filter(deleted.eq(false))
+      .filter(removed.eq(false))
+      .filter(featured_community.eq(true))
+      .then_order_by(published.desc())
+      .limit(FETCH_LIMIT_MAX)
+      .load::<Self>(conn)
+      .await
+  }
+
   pub async fn permadelete_for_creator(
     pool: &DbPool,
     for_creator_id: PersonId,