]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/aggregates/community_aggregates.rs
Making community_follower.pending column not null.
[lemmy.git] / crates / db_schema / src / aggregates / community_aggregates.rs
index d80425e1731245b7daf92071573fb75a69ff9418..fc8cf0b063c40ebd936b4580102af10f937cd273 100644 (file)
@@ -1,23 +1,9 @@
-use crate::{newtypes::CommunityId, schema::community_aggregates};
+use crate::{
+  aggregates::structs::CommunityAggregates,
+  newtypes::CommunityId,
+  schema::community_aggregates,
+};
 use diesel::{result::Error, *};
-use serde::{Deserialize, Serialize};
-
-#[derive(
-  Queryable, Associations, Identifiable, PartialEq, Debug, Serialize, Deserialize, Clone,
-)]
-#[table_name = "community_aggregates"]
-pub struct CommunityAggregates {
-  pub id: i32,
-  pub community_id: CommunityId,
-  pub subscribers: i64,
-  pub posts: i64,
-  pub comments: i64,
-  pub published: chrono::NaiveDateTime,
-  pub users_active_day: i64,
-  pub users_active_week: i64,
-  pub users_active_month: i64,
-  pub users_active_half_year: i64,
-}
 
 impl CommunityAggregates {
   pub fn read(conn: &PgConnection, community_id: CommunityId) -> Result<Self, Error> {
@@ -31,7 +17,6 @@ impl CommunityAggregates {
 mod tests {
   use crate::{
     aggregates::community_aggregates::CommunityAggregates,
-    establish_unpooled_connection,
     source::{
       comment::{Comment, CommentForm},
       community::{Community, CommunityFollower, CommunityFollowerForm, CommunityForm},
@@ -39,6 +24,7 @@ mod tests {
       post::{Post, PostForm},
     },
     traits::{Crud, Followable},
+    utils::establish_unpooled_connection,
   };
   use serial_test::serial;
 
@@ -80,7 +66,7 @@ mod tests {
     let first_person_follow = CommunityFollowerForm {
       community_id: inserted_community.id,
       person_id: inserted_person.id,
-      pending: false,
+      pending: Some(false),
     };
 
     CommunityFollower::follow(&conn, &first_person_follow).unwrap();
@@ -88,7 +74,7 @@ mod tests {
     let second_person_follow = CommunityFollowerForm {
       community_id: inserted_community.id,
       person_id: another_inserted_person.id,
-      pending: false,
+      pending: Some(false),
     };
 
     CommunityFollower::follow(&conn, &second_person_follow).unwrap();
@@ -96,7 +82,7 @@ mod tests {
     let another_community_follow = CommunityFollowerForm {
       community_id: another_inserted_community.id,
       person_id: inserted_person.id,
-      pending: false,
+      pending: Some(false),
     };
 
     CommunityFollower::follow(&conn, &another_community_follow).unwrap();