]> Untitled Git - lemmy.git/blobdiff - crates/db_schema/src/aggregates/structs.rs
implement language tags for site/community in db and api (#2434)
[lemmy.git] / crates / db_schema / src / aggregates / structs.rs
index 15fce13b2bb849d00d6167dabfa682702bf653fc..ab87f4580086861d8c4ba11c5d88ec40965ef914 100644 (file)
@@ -6,6 +6,7 @@ use crate::schema::{
   comment_aggregates,
   community_aggregates,
   person_aggregates,
+  person_post_aggregates,
   post_aggregates,
   site_aggregates,
 };
@@ -74,6 +75,28 @@ pub struct PostAggregates {
   pub newest_comment_time: chrono::NaiveDateTime,
 }
 
+#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
+#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
+#[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
+#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
+pub struct PersonPostAggregates {
+  pub id: i32,
+  pub person_id: PersonId,
+  pub post_id: PostId,
+  pub read_comments: i64,
+  pub published: chrono::NaiveDateTime,
+}
+
+#[derive(Clone, Default)]
+#[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
+#[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
+pub struct PersonPostAggregatesForm {
+  pub person_id: PersonId,
+  pub post_id: PostId,
+  pub read_comments: i64,
+  pub published: Option<chrono::NaiveDateTime>,
+}
+
 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
 #[cfg_attr(feature = "full", diesel(table_name = site_aggregates))]