2023-09-20 09:56:13 +00:00
|
|
|
use crate::newtypes::{CommentId, CommunityId, InstanceId, PersonId, PostId, SiteId};
|
2022-05-03 17:44:13 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use crate::schema::{
|
|
|
|
comment_aggregates,
|
|
|
|
community_aggregates,
|
|
|
|
person_aggregates,
|
2022-09-27 16:45:46 +00:00
|
|
|
person_post_aggregates,
|
2022-05-03 17:44:13 +00:00
|
|
|
post_aggregates,
|
|
|
|
site_aggregates,
|
|
|
|
};
|
2023-08-24 15:27:00 +00:00
|
|
|
use chrono::{DateTime, Utc};
|
2022-11-02 19:18:22 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg(feature = "full")]
|
|
|
|
use ts_rs::TS;
|
2023-07-26 17:07:05 +00:00
|
|
|
#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
derive(Queryable, Selectable, Associations, Identifiable, TS)
|
|
|
|
)]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = comment_aggregates))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::comment::Comment)))]
|
Remove id column and use different primary key on some tables (#4093)
* post_saved
* fmt
* remove unique and not null
* put person_id first in primary key and remove index
* use post_saved.find
* change captcha_answer
* remove removal of not null
* comment_aggregates
* comment_like
* comment_saved
* aggregates
* remove "\"
* deduplicate site_aggregates
* person_post_aggregates
* community_moderator
* community_block
* community_person_ban
* custom_emoji_keyword
* federation allow/block list
* federation_queue_state
* instance_block
* local_site_rate_limit, local_user_language, login_token
* person_ban, person_block, person_follower, post_like, post_read, received_activity
* community_follower, community_language, site_language
* fmt
* image_upload
* remove unused newtypes
* remove more indexes
* use .find
* merge
* fix site_aggregates_site function
* fmt
* Primary keys dess (#17)
* Also order reports by oldest first (ref #4123) (#4129)
* Support signed fetch for federation (fixes #868) (#4125)
* Support signed fetch for federation (fixes #868)
* taplo
* add federation queue state to get_federated_instances api (#4104)
* add federation queue state to get_federated_instances api
* feature gate
* move retry sleep function
* move stuff around
* Add UI setting for collapsing bot comments. Fixes #3838 (#4098)
* Add UI setting for collapsing bot comments. Fixes #3838
* Fixing clippy check.
* Only keep sent and received activities for 7 days (fixes #4113, fixes #4110) (#4131)
* Only check auth secure on release mode. (#4127)
* Only check auth secure on release mode.
* Fixing wrong js-client.
* Adding is_debug_mode var.
* Fixing the desktop image on the README. (#4135)
* Delete dupes and add possibly missing unique constraint on person_aggregates.
* Fixing clippy lints.
---------
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
* fmt
* Update community_block.rs
* Update instance_block.rs
* Update person_block.rs
* Update person_block.rs
---------
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
2023-11-13 13:14:07 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(primary_key(comment_id)))]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Aggregate data for a comment.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommentAggregates {
|
|
|
|
pub comment_id: CommentId,
|
|
|
|
pub score: i64,
|
|
|
|
pub upvotes: i64,
|
|
|
|
pub downvotes: i64,
|
2023-08-24 15:27:00 +00:00
|
|
|
pub published: DateTime<Utc>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The total number of children in this comment branch.
|
2022-07-30 03:55:59 +00:00
|
|
|
pub child_count: i32,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-09-06 17:43:27 +00:00
|
|
|
pub hot_rank: f64,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-07-26 17:07:05 +00:00
|
|
|
pub controversy_rank: f64,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2023-09-06 17:43:27 +00:00
|
|
|
#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
derive(Queryable, Selectable, Associations, Identifiable, TS)
|
|
|
|
)]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = community_aggregates))]
|
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
diesel(belongs_to(crate::source::community::Community))
|
|
|
|
)]
|
Remove id column and use different primary key on some tables (#4093)
* post_saved
* fmt
* remove unique and not null
* put person_id first in primary key and remove index
* use post_saved.find
* change captcha_answer
* remove removal of not null
* comment_aggregates
* comment_like
* comment_saved
* aggregates
* remove "\"
* deduplicate site_aggregates
* person_post_aggregates
* community_moderator
* community_block
* community_person_ban
* custom_emoji_keyword
* federation allow/block list
* federation_queue_state
* instance_block
* local_site_rate_limit, local_user_language, login_token
* person_ban, person_block, person_follower, post_like, post_read, received_activity
* community_follower, community_language, site_language
* fmt
* image_upload
* remove unused newtypes
* remove more indexes
* use .find
* merge
* fix site_aggregates_site function
* fmt
* Primary keys dess (#17)
* Also order reports by oldest first (ref #4123) (#4129)
* Support signed fetch for federation (fixes #868) (#4125)
* Support signed fetch for federation (fixes #868)
* taplo
* add federation queue state to get_federated_instances api (#4104)
* add federation queue state to get_federated_instances api
* feature gate
* move retry sleep function
* move stuff around
* Add UI setting for collapsing bot comments. Fixes #3838 (#4098)
* Add UI setting for collapsing bot comments. Fixes #3838
* Fixing clippy check.
* Only keep sent and received activities for 7 days (fixes #4113, fixes #4110) (#4131)
* Only check auth secure on release mode. (#4127)
* Only check auth secure on release mode.
* Fixing wrong js-client.
* Adding is_debug_mode var.
* Fixing the desktop image on the README. (#4135)
* Delete dupes and add possibly missing unique constraint on person_aggregates.
* Fixing clippy lints.
---------
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
* fmt
* Update community_block.rs
* Update instance_block.rs
* Update person_block.rs
* Update person_block.rs
---------
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
2023-11-13 13:14:07 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(primary_key(community_id)))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Aggregate data for a community.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct CommunityAggregates {
|
|
|
|
pub community_id: CommunityId,
|
|
|
|
pub subscribers: i64,
|
|
|
|
pub posts: i64,
|
|
|
|
pub comments: i64,
|
2023-08-24 15:27:00 +00:00
|
|
|
pub published: DateTime<Utc>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of users with any activity in the last day.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users_active_day: i64,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of users with any activity in the last week.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users_active_week: i64,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of users with any activity in the last month.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users_active_month: i64,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of users with any activity in the last year.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users_active_half_year: i64,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-09-06 17:43:27 +00:00
|
|
|
pub hot_rank: f64,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone, Default)]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
derive(Queryable, Selectable, Associations, Identifiable, TS)
|
|
|
|
)]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = person_aggregates))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
|
Remove id column and use different primary key on some tables (#4093)
* post_saved
* fmt
* remove unique and not null
* put person_id first in primary key and remove index
* use post_saved.find
* change captcha_answer
* remove removal of not null
* comment_aggregates
* comment_like
* comment_saved
* aggregates
* remove "\"
* deduplicate site_aggregates
* person_post_aggregates
* community_moderator
* community_block
* community_person_ban
* custom_emoji_keyword
* federation allow/block list
* federation_queue_state
* instance_block
* local_site_rate_limit, local_user_language, login_token
* person_ban, person_block, person_follower, post_like, post_read, received_activity
* community_follower, community_language, site_language
* fmt
* image_upload
* remove unused newtypes
* remove more indexes
* use .find
* merge
* fix site_aggregates_site function
* fmt
* Primary keys dess (#17)
* Also order reports by oldest first (ref #4123) (#4129)
* Support signed fetch for federation (fixes #868) (#4125)
* Support signed fetch for federation (fixes #868)
* taplo
* add federation queue state to get_federated_instances api (#4104)
* add federation queue state to get_federated_instances api
* feature gate
* move retry sleep function
* move stuff around
* Add UI setting for collapsing bot comments. Fixes #3838 (#4098)
* Add UI setting for collapsing bot comments. Fixes #3838
* Fixing clippy check.
* Only keep sent and received activities for 7 days (fixes #4113, fixes #4110) (#4131)
* Only check auth secure on release mode. (#4127)
* Only check auth secure on release mode.
* Fixing wrong js-client.
* Adding is_debug_mode var.
* Fixing the desktop image on the README. (#4135)
* Delete dupes and add possibly missing unique constraint on person_aggregates.
* Fixing clippy lints.
---------
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
* fmt
* Update community_block.rs
* Update instance_block.rs
* Update person_block.rs
* Update person_block.rs
---------
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
2023-11-13 13:14:07 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(primary_key(person_id)))]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Aggregate data for a person.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct PersonAggregates {
|
|
|
|
pub person_id: PersonId,
|
|
|
|
pub post_count: i64,
|
2023-10-24 21:26:09 +00:00
|
|
|
#[serde(skip)]
|
2022-05-03 17:44:13 +00:00
|
|
|
pub post_score: i64,
|
|
|
|
pub comment_count: i64,
|
2023-10-24 21:26:09 +00:00
|
|
|
#[serde(skip)]
|
2022-05-03 17:44:13 +00:00
|
|
|
pub comment_score: i64,
|
|
|
|
}
|
|
|
|
|
2023-07-26 17:07:05 +00:00
|
|
|
#[derive(PartialEq, Debug, Serialize, Deserialize, Clone)]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
derive(Queryable, Selectable, Associations, Identifiable, TS)
|
|
|
|
)]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = post_aggregates))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::post::Post)))]
|
Remove id column and use different primary key on some tables (#4093)
* post_saved
* fmt
* remove unique and not null
* put person_id first in primary key and remove index
* use post_saved.find
* change captcha_answer
* remove removal of not null
* comment_aggregates
* comment_like
* comment_saved
* aggregates
* remove "\"
* deduplicate site_aggregates
* person_post_aggregates
* community_moderator
* community_block
* community_person_ban
* custom_emoji_keyword
* federation allow/block list
* federation_queue_state
* instance_block
* local_site_rate_limit, local_user_language, login_token
* person_ban, person_block, person_follower, post_like, post_read, received_activity
* community_follower, community_language, site_language
* fmt
* image_upload
* remove unused newtypes
* remove more indexes
* use .find
* merge
* fix site_aggregates_site function
* fmt
* Primary keys dess (#17)
* Also order reports by oldest first (ref #4123) (#4129)
* Support signed fetch for federation (fixes #868) (#4125)
* Support signed fetch for federation (fixes #868)
* taplo
* add federation queue state to get_federated_instances api (#4104)
* add federation queue state to get_federated_instances api
* feature gate
* move retry sleep function
* move stuff around
* Add UI setting for collapsing bot comments. Fixes #3838 (#4098)
* Add UI setting for collapsing bot comments. Fixes #3838
* Fixing clippy check.
* Only keep sent and received activities for 7 days (fixes #4113, fixes #4110) (#4131)
* Only check auth secure on release mode. (#4127)
* Only check auth secure on release mode.
* Fixing wrong js-client.
* Adding is_debug_mode var.
* Fixing the desktop image on the README. (#4135)
* Delete dupes and add possibly missing unique constraint on person_aggregates.
* Fixing clippy lints.
---------
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
* fmt
* Update community_block.rs
* Update instance_block.rs
* Update person_block.rs
* Update person_block.rs
---------
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
2023-11-13 13:14:07 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(primary_key(post_id)))]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Aggregate data for a post.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct PostAggregates {
|
|
|
|
pub post_id: PostId,
|
|
|
|
pub comments: i64,
|
|
|
|
pub score: i64,
|
|
|
|
pub upvotes: i64,
|
|
|
|
pub downvotes: i64,
|
2023-08-24 15:27:00 +00:00
|
|
|
pub published: DateTime<Utc>,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
|
|
|
/// A newest comment time, limited to 2 days, to prevent necrobumping
|
2023-08-24 15:27:00 +00:00
|
|
|
pub newest_comment_time_necro: DateTime<Utc>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The time of the newest comment in the post.
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-08-24 15:27:00 +00:00
|
|
|
pub newest_comment_time: DateTime<Utc>,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// If the post is featured on the community.
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2022-12-12 11:17:10 +00:00
|
|
|
pub featured_community: bool,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// If the post is featured on the site / to local.
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2022-12-12 11:17:10 +00:00
|
|
|
pub featured_local: bool,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-09-06 17:43:27 +00:00
|
|
|
pub hot_rank: f64,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-09-06 17:43:27 +00:00
|
|
|
pub hot_rank_active: f64,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-07-20 15:13:21 +00:00
|
|
|
pub community_id: CommunityId,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-07-20 15:13:21 +00:00
|
|
|
pub creator_id: PersonId,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-07-26 17:07:05 +00:00
|
|
|
pub controversy_rank: f64,
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-09-20 09:56:13 +00:00
|
|
|
pub instance_id: InstanceId,
|
2023-09-06 17:43:27 +00:00
|
|
|
/// A rank that amplifies smaller communities
|
2023-10-16 23:37:28 +00:00
|
|
|
#[serde(skip)]
|
2023-09-06 17:43:27 +00:00
|
|
|
pub scaled_rank: f64,
|
2022-05-03 17:44:13 +00:00
|
|
|
}
|
|
|
|
|
2022-09-26 14:09:32 +00:00
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
derive(Queryable, Selectable, Associations, Identifiable)
|
|
|
|
)]
|
2022-09-27 16:45:46 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = person_post_aggregates))]
|
Remove id column and use different primary key on some tables (#4093)
* post_saved
* fmt
* remove unique and not null
* put person_id first in primary key and remove index
* use post_saved.find
* change captcha_answer
* remove removal of not null
* comment_aggregates
* comment_like
* comment_saved
* aggregates
* remove "\"
* deduplicate site_aggregates
* person_post_aggregates
* community_moderator
* community_block
* community_person_ban
* custom_emoji_keyword
* federation allow/block list
* federation_queue_state
* instance_block
* local_site_rate_limit, local_user_language, login_token
* person_ban, person_block, person_follower, post_like, post_read, received_activity
* community_follower, community_language, site_language
* fmt
* image_upload
* remove unused newtypes
* remove more indexes
* use .find
* merge
* fix site_aggregates_site function
* fmt
* Primary keys dess (#17)
* Also order reports by oldest first (ref #4123) (#4129)
* Support signed fetch for federation (fixes #868) (#4125)
* Support signed fetch for federation (fixes #868)
* taplo
* add federation queue state to get_federated_instances api (#4104)
* add federation queue state to get_federated_instances api
* feature gate
* move retry sleep function
* move stuff around
* Add UI setting for collapsing bot comments. Fixes #3838 (#4098)
* Add UI setting for collapsing bot comments. Fixes #3838
* Fixing clippy check.
* Only keep sent and received activities for 7 days (fixes #4113, fixes #4110) (#4131)
* Only check auth secure on release mode. (#4127)
* Only check auth secure on release mode.
* Fixing wrong js-client.
* Adding is_debug_mode var.
* Fixing the desktop image on the README. (#4135)
* Delete dupes and add possibly missing unique constraint on person_aggregates.
* Fixing clippy lints.
---------
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
* fmt
* Update community_block.rs
* Update instance_block.rs
* Update person_block.rs
* Update person_block.rs
---------
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
2023-11-13 13:14:07 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(primary_key(person_id, post_id)))]
|
2022-09-27 16:45:46 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::person::Person)))]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Aggregate data for a person's post.
|
2022-09-27 16:45:46 +00:00
|
|
|
pub struct PersonPostAggregates {
|
|
|
|
pub person_id: PersonId,
|
|
|
|
pub post_id: PostId,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of comments they've read on that post.
|
|
|
|
///
|
|
|
|
/// This is updated to the current post comment count every time they view a post.
|
2022-09-27 16:45:46 +00:00
|
|
|
pub read_comments: i64,
|
2023-08-24 15:27:00 +00:00
|
|
|
pub published: DateTime<Utc>,
|
2022-09-27 16:45:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[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,
|
2023-08-24 15:27:00 +00:00
|
|
|
pub published: Option<DateTime<Utc>>,
|
2022-09-27 16:45:46 +00:00
|
|
|
}
|
|
|
|
|
2022-10-06 18:27:58 +00:00
|
|
|
#[derive(PartialEq, Eq, Debug, Serialize, Deserialize, Clone)]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(
|
|
|
|
feature = "full",
|
|
|
|
derive(Queryable, Selectable, Associations, Identifiable, TS)
|
|
|
|
)]
|
2022-09-26 14:09:32 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(table_name = site_aggregates))]
|
|
|
|
#[cfg_attr(feature = "full", diesel(belongs_to(crate::source::site::Site)))]
|
Remove id column and use different primary key on some tables (#4093)
* post_saved
* fmt
* remove unique and not null
* put person_id first in primary key and remove index
* use post_saved.find
* change captcha_answer
* remove removal of not null
* comment_aggregates
* comment_like
* comment_saved
* aggregates
* remove "\"
* deduplicate site_aggregates
* person_post_aggregates
* community_moderator
* community_block
* community_person_ban
* custom_emoji_keyword
* federation allow/block list
* federation_queue_state
* instance_block
* local_site_rate_limit, local_user_language, login_token
* person_ban, person_block, person_follower, post_like, post_read, received_activity
* community_follower, community_language, site_language
* fmt
* image_upload
* remove unused newtypes
* remove more indexes
* use .find
* merge
* fix site_aggregates_site function
* fmt
* Primary keys dess (#17)
* Also order reports by oldest first (ref #4123) (#4129)
* Support signed fetch for federation (fixes #868) (#4125)
* Support signed fetch for federation (fixes #868)
* taplo
* add federation queue state to get_federated_instances api (#4104)
* add federation queue state to get_federated_instances api
* feature gate
* move retry sleep function
* move stuff around
* Add UI setting for collapsing bot comments. Fixes #3838 (#4098)
* Add UI setting for collapsing bot comments. Fixes #3838
* Fixing clippy check.
* Only keep sent and received activities for 7 days (fixes #4113, fixes #4110) (#4131)
* Only check auth secure on release mode. (#4127)
* Only check auth secure on release mode.
* Fixing wrong js-client.
* Adding is_debug_mode var.
* Fixing the desktop image on the README. (#4135)
* Delete dupes and add possibly missing unique constraint on person_aggregates.
* Fixing clippy lints.
---------
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
* fmt
* Update community_block.rs
* Update instance_block.rs
* Update person_block.rs
* Update person_block.rs
---------
Co-authored-by: Dessalines <dessalines@users.noreply.github.com>
Co-authored-by: Nutomic <me@nutomic.com>
Co-authored-by: phiresky <phireskyde+git@gmail.com>
2023-11-13 13:14:07 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(primary_key(site_id)))]
|
2023-11-21 13:42:28 +00:00
|
|
|
#[cfg_attr(feature = "full", diesel(check_for_backend(diesel::pg::Pg)))]
|
2023-04-26 04:26:10 +00:00
|
|
|
#[cfg_attr(feature = "full", ts(export))]
|
2023-05-10 19:20:39 +00:00
|
|
|
/// Aggregate data for a site.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub struct SiteAggregates {
|
2022-11-09 10:05:00 +00:00
|
|
|
pub site_id: SiteId,
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users: i64,
|
|
|
|
pub posts: i64,
|
|
|
|
pub comments: i64,
|
|
|
|
pub communities: i64,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of users with any activity in the last day.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users_active_day: i64,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of users with any activity in the last week.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users_active_week: i64,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of users with any activity in the last month.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users_active_month: i64,
|
2023-05-10 19:20:39 +00:00
|
|
|
/// The number of users with any activity in the last half year.
|
2022-05-03 17:44:13 +00:00
|
|
|
pub users_active_half_year: i64,
|
|
|
|
}
|