1 use crate::newtypes::{CommentId, CommunityId, PersonId, PostId};
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 {
72 pub published: chrono::NaiveDateTime,
73 pub newest_comment_time_necro: chrono::NaiveDateTime, // A newest comment time, limited to 2 days, to prevent necrobumping
74 pub newest_comment_time: chrono::NaiveDateTime,
77 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
78 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
79 #[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
80 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
81 pub struct PersonPostAggregates {
83 pub person_id: PersonId,
85 pub read_comments: i64,
86 pub published: chrono::NaiveDateTime,
89 #[derive(Clone, Default)]
90 #[cfg_attr(feature = "full", derive(Insertable, AsChangeset))]
91 #[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
92 pub struct PersonPostAggregatesForm {
93 pub person_id: PersonId,
95 pub read_comments: i64,
96 pub published: Option<chrono::NaiveDateTime>,
99 #[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
100 #[cfg_attr(feature = "full", derive(Queryable, Associations, Identifiable))]
101 #[cfg_attr(feature = "full", diesel(table_name = site_aggregates))]
102 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
103 pub struct SiteAggregates {
109 pub communities: i64,
110 pub users_active_day: i64,
111 pub users_active_week: i64,
112 pub users_active_month: i64,
113 pub users_active_half_year: i64,