]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/aggregates/comment_aggregates.rs
Make functions work with both connection and pool (#3420)
[lemmy.git] / crates / db_schema / src / aggregates / comment_aggregates.rs
index 5a5550a2ec2920f83049946a7cd9e9ce2d0d18c1..12b57222805cc23e82484e98085016599d697d95 100644 (file)
@@ -8,7 +8,7 @@ use diesel::{result::Error, ExpressionMethods, QueryDsl};
 use diesel_async::RunQueryDsl;
 
 impl CommentAggregates {
-  pub async fn read(pool: &DbPool, comment_id: CommentId) -> Result<Self, Error> {
+  pub async fn read(pool: &mut DbPool<'_>, comment_id: CommentId) -> Result<Self, Error> {
     let conn = &mut get_conn(pool).await?;
     comment_aggregates::table
       .filter(comment_aggregates::comment_id.eq(comment_id))
@@ -16,7 +16,10 @@ impl CommentAggregates {
       .await
   }
 
-  pub async fn update_hot_rank(pool: &DbPool, comment_id: CommentId) -> Result<Self, Error> {
+  pub async fn update_hot_rank(
+    pool: &mut DbPool<'_>,
+    comment_id: CommentId,
+  ) -> Result<Self, Error> {
     let conn = &mut get_conn(pool).await?;
 
     diesel::update(comment_aggregates::table)
@@ -50,6 +53,7 @@ mod tests {
   #[serial]
   async fn test_crud() {
     let pool = &build_db_pool_for_tests().await;
+    let pool = &mut pool.into();
 
     let inserted_instance = Instance::read_or_create(pool, "my_domain.tld".to_string())
       .await