]> 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 407a83f5369b660d57a1a013abc0ed18181888df..9f5c64389b5f735343bbd932ce766cf7e3599d7c 100644 (file)
@@ -6,11 +6,11 @@ use crate::{
     community_id,
     creator_id,
     deleted,
+    featured_community,
     name,
     post,
     published,
     removed,
-    stickied,
     thumbnail_url,
     updated,
     url,
@@ -82,8 +82,24 @@ impl Post {
       .filter(community_id.eq(the_community_id))
       .filter(deleted.eq(false))
       .filter(removed.eq(false))
+      .then_order_by(featured_community.desc())
+      .then_order_by(published.desc())
+      .limit(FETCH_LIMIT_MAX)
+      .load::<Self>(conn)
+      .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())
-      .then_order_by(stickied.desc())
       .limit(FETCH_LIMIT_MAX)
       .load::<Self>(conn)
       .await
@@ -381,7 +397,6 @@ mod tests {
       published: inserted_post.published,
       removed: false,
       locked: false,
-      stickied: false,
       nsfw: false,
       deleted: false,
       updated: None,
@@ -392,6 +407,8 @@ mod tests {
       ap_id: inserted_post.ap_id.clone(),
       local: true,
       language_id: Default::default(),
+      featured_community: false,
+      featured_local: false,
     };
 
     // Post Like