1 use crate::newtypes::{CommentId, CommunityId, PersonId, PostId, SiteId};
2 #[cfg(feature = "full")]
7 person_post_aggregates,
11 use serde::{Deserialize, Serialize};
13 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
14 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
15 #[cfg_attr(feature = "full", diesel(table_name = comment_aggregates))]
16 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))]
17 pub struct CommentAggregates {
19 pub comment_id: CommentId,
23 pub published: chrono::NaiveDateTime,
27 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
28 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
29 #[cfg_attr(feature = "full", diesel(table_name = community_aggregates))]
32 diesel(belongs_to(crate::source::community::Community))
34 pub struct CommunityAggregates {
36 pub community_id: CommunityId,
40 pub published: chrono::NaiveDateTime,
41 pub users_active_day: i64,
42 pub users_active_week: i64,
43 pub users_active_month: i64,
44 pub users_active_half_year: i64,
47 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)]
48 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
49 #[cfg_attr(feature = "full", diesel(table_name = person_aggregates))]
50 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
51 pub struct PersonAggregates {
53 pub person_id: PersonId,
56 pub comment_count: i64,
57 pub comment_score: i64,
60 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
61 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
62 #[cfg_attr(feature = "full", diesel(table_name = post_aggregates))]
63 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
64 pub struct PostAggregates {
71 pub published: chrono::NaiveDateTime,
72 pub newest_comment_time_necro: chrono::NaiveDateTime, // A newest comment time, limited to 2 days, to prevent necrobumping
73 pub newest_comment_time: chrono::NaiveDateTime,
74 pub featured_community: bool,
75 pub featured_local: bool,
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, Eq, 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,