1 use crate::newtypes::{CommentId, CommunityId, PersonId, PostId};
2 use serde::{Deserialize, Serialize};
4 #[cfg(feature = "full")]
9 person_post_aggregates,
14 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
15 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
16 #[cfg_attr(feature = "full", diesel(table_name = comment_aggregates))]
17 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))]
18 pub struct CommentAggregates {
20 pub comment_id: CommentId,
24 pub published: chrono::NaiveDateTime,
28 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
29 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
30 #[cfg_attr(feature = "full", diesel(table_name = community_aggregates))]
33 diesel(belongs_to(crate::source::community::Community))
35 pub struct CommunityAggregates {
37 pub community_id: CommunityId,
41 pub published: chrono::NaiveDateTime,
42 pub users_active_day: i64,
43 pub users_active_week: i64,
44 pub users_active_month: i64,
45 pub users_active_half_year: i64,
48 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)]
49 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
50 #[cfg_attr(feature = "full", diesel(table_name = person_aggregates))]
51 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
52 pub struct PersonAggregates {
54 pub person_id: PersonId,
57 pub comment_count: i64,
58 pub comment_score: i64,
61 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
62 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
63 #[cfg_attr(feature = "full", diesel(table_name = post_aggregates))]
64 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
65 pub struct PostAggregates {
73 pub published: chrono::NaiveDateTime,
74 pub newest_comment_time_necro: chrono::NaiveDateTime, // A newest comment time, limited to 2 days, to prevent necrobumping
75 pub newest_comment_time: chrono::NaiveDateTime,
78 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
79 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
80 #[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
81 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
82 pub struct PersonPostAggregates {
84 pub person_id: PersonId,
86 pub read_comments: i64,
87 pub published: chrono::NaiveDateTime,
90 #[derive(Clone, Default)]
91 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
92 #[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
93 pub struct PersonPostAggregatesForm {
94 pub person_id: PersonId,
96 pub read_comments: i64,
97 pub published: Option<chrono::NaiveDateTime>,
100 #[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
101 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
102 #[cfg_attr(feature = "full", diesel(table_name = site_aggregates))]
103 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
104 pub struct SiteAggregates {
110 pub communities: i64,
111 pub users_active_day: i64,
112 pub users_active_week: i64,
113 pub users_active_month: i64,
114 pub users_active_half_year: i64,