1 use crate::newtypes::{CommentId, CommunityId, PersonId, PostId};
2 use serde::{Deserialize, Serialize};
4 #[cfg(feature = "full")]
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 = site_aggregates))]
80 #[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
81 pub struct SiteAggregates {
88 pub users_active_day: i64,
89 pub users_active_week: i64,
90 pub users_active_month: i64,
91 pub users_active_half_year: i64,