]> Untitled Git - lemmy.git/blobdiff - crates/db_views/src/post_view.rs
Feature add three six and nine months options backend (#3226)
[lemmy.git] / crates / db_views / src / post_view.rs
index 14cf7fe1976e3832b2515d60839de9708997d339..d1e974d8a107290211abbfb034bcde694116ede6 100644 (file)
@@ -430,6 +430,18 @@ impl<'a> PostQuery<'a> {
         .filter(post_aggregates::published.gt(now - 12.hours()))
         .then_order_by(post_aggregates::score.desc())
         .then_order_by(post_aggregates::published.desc()),
+      SortType::TopThreeMonths => query
+        .filter(post_aggregates::published.gt(now - 3.months()))
+        .then_order_by(post_aggregates::score.desc())
+        .then_order_by(post_aggregates::published.desc()),
+      SortType::TopSixMonths => query
+        .filter(post_aggregates::published.gt(now - 6.months()))
+        .then_order_by(post_aggregates::score.desc())
+        .then_order_by(post_aggregates::published.desc()),
+      SortType::TopNineMonths => query
+        .filter(post_aggregates::published.gt(now - 9.months()))
+        .then_order_by(post_aggregates::score.desc())
+        .then_order_by(post_aggregates::published.desc()),
     };
 
     let (limit, offset) = limit_and_offset(self.page, self.limit)?;