1 use crate::newtypes::LocalSiteId;
2 use serde::{Deserialize, Serialize};
3 use typed_builder::TypedBuilder;
5 #[cfg(feature = "full")]
6 use crate::schema::local_site_rate_limit;
8 #[derive(PartialEq, Eq, Debug, Clone, Serialize, Deserialize)]
9 #[cfg_attr(feature = "full", derive(Queryable, Identifiable))]
10 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
13 diesel(belongs_to(crate::source::local_site::LocalSite))
15 pub struct LocalSiteRateLimit {
17 pub local_site_id: LocalSiteId,
19 pub message_per_second: i32,
21 pub post_per_second: i32,
23 pub register_per_second: i32,
25 pub image_per_second: i32,
27 pub comment_per_second: i32,
29 pub search_per_second: i32,
30 pub published: chrono::NaiveDateTime,
31 pub updated: Option<chrono::NaiveDateTime>,
34 #[derive(Clone, TypedBuilder)]
35 #[builder(field_defaults(default))]
36 #[cfg_attr(feature = "full", derive(Insertable))]
37 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
38 pub struct LocalSiteRateLimitInsertForm {
40 pub local_site_id: LocalSiteId,
41 pub message: Option<i32>,
42 pub message_per_second: Option<i32>,
43 pub post: Option<i32>,
44 pub post_per_second: Option<i32>,
45 pub register: Option<i32>,
46 pub register_per_second: Option<i32>,
47 pub image: Option<i32>,
48 pub image_per_second: Option<i32>,
49 pub comment: Option<i32>,
50 pub comment_per_second: Option<i32>,
51 pub search: Option<i32>,
52 pub search_per_second: Option<i32>,
55 #[derive(Clone, TypedBuilder)]
56 #[builder(field_defaults(default))]
57 #[cfg_attr(feature = "full", derive(AsChangeset))]
58 #[cfg_attr(feature = "full", diesel(table_name = local_site_rate_limit))]
59 pub struct LocalSiteRateLimitUpdateForm {
60 pub message: Option<i32>,
61 pub message_per_second: Option<i32>,
62 pub post: Option<i32>,
63 pub post_per_second: Option<i32>,
64 pub register: Option<i32>,
65 pub register_per_second: Option<i32>,
66 pub image: Option<i32>,
67 pub image_per_second: Option<i32>,
68 pub comment: Option<i32>,
69 pub comment_per_second: Option<i32>,
70 pub search: Option<i32>,
71 pub search_per_second: Option<i32>,
72 pub updated: Option<Option<chrono::NaiveDateTime>>,