]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/utils.rs
Feature add hours as sorting options backend (#3161)
[lemmy.git] / crates / db_schema / src / utils.rs
index c05cd565d0dc487c61967f17376d54624959427c..98d3952abc1c5d2b96ad9de1eaf8ad73cfd9f663 100644 (file)
@@ -5,7 +5,7 @@ use crate::{
   CommentSortType,
   SortType,
 };
-use activitypub_federation::{core::object_id::ObjectId, traits::ApubObject};
+use activitypub_federation::{fetch::object_id::ObjectId, traits::Object};
 use chrono::NaiveDateTime;
 use deadpool::Runtime;
 use diesel::{
@@ -196,7 +196,10 @@ pub fn post_to_comment_sort_type(sort: SortType) -> CommentSortType {
     SortType::Active | SortType::Hot => CommentSortType::Hot,
     SortType::New | SortType::NewComments | SortType::MostComments => CommentSortType::New,
     SortType::Old => CommentSortType::Old,
-    SortType::TopDay
+    SortType::TopHour
+    | SortType::TopSixHour
+    | SortType::TopTwelveHour
+    | SortType::TopDay
     | SortType::TopAll
     | SortType::TopWeek
     | SortType::TopYear
@@ -229,7 +232,7 @@ impl<DB: Backend> FromSql<Text, DB> for DbUrl
 where
   String: FromSql<Text, DB>,
 {
-  fn from_sql(value: diesel::backend::RawValue<'_, DB>) -> diesel::deserialize::Result<Self> {
+  fn from_sql(value: DB::RawValue<'_>) -> diesel::deserialize::Result<Self> {
     let str = String::from_sql(value)?;
     Ok(DbUrl(Box::new(Url::parse(&str)?)))
   }
@@ -237,8 +240,8 @@ where
 
 impl<Kind> From<ObjectId<Kind>> for DbUrl
 where
-  Kind: ApubObject + Send + 'static,
-  for<'de2> <Kind as ApubObject>::ApubType: serde::Deserialize<'de2>,
+  Kind: Object + Send + 'static,
+  for<'de2> <Kind as Object>::Kind: serde::Deserialize<'de2>,
 {
   fn from(id: ObjectId<Kind>) -> Self {
     DbUrl(Box::new(id.into()))