comment_aggregates,
community_aggregates,
person_aggregates,
+ person_post_aggregates,
post_aggregates,
site_aggregates,
};
-#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
+#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
-#[cfg_attr(feature = "full", table_name = "comment_aggregates")]
+#[cfg_attr(feature = "full", diesel(table_name = comment_aggregates))]
+#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))]
pub struct CommentAggregates {
pub id: i32,
pub comment_id: CommentId,
pub child_count: i32,
}
-#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
+#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
-#[cfg_attr(feature = "full", table_name = "community_aggregates")]
+#[cfg_attr(feature = "full", diesel(table_name = community_aggregates))]
+#[cfg_attr(
+ feature = "full",
+ diesel(belongs_to(crate::source::community::Community))
+)]
pub struct CommunityAggregates {
pub id: i32,
pub community_id: CommunityId,
pub users_active_half_year: i64,
}
-#[derive(PartialEq, Debug, Serialize, Deserialize, Clone, Default)]
+#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)]
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
-#[cfg_attr(feature = "full", table_name = "person_aggregates")]
+#[cfg_attr(feature = "full", diesel(table_name = person_aggregates))]
+#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
pub struct PersonAggregates {
pub id: i32,
pub person_id: PersonId,
pub comment_score: i64,
}
-#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
+#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
-#[cfg_attr(feature = "full", table_name = "post_aggregates")]
+#[cfg_attr(feature = "full", diesel(table_name = post_aggregates))]
+#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
pub struct PostAggregates {
pub id: i32,
pub post_id: PostId,
pub newest_comment_time: chrono::NaiveDateTime,
}
-#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
+#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
#[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
-#[cfg_attr(feature = "full", table_name = "site_aggregates")]
+#[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))]
+#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
pub struct SiteAggregates {
pub id: i32,
pub site_id: i32,