1 use crate::limit_and_offset;
2 use diesel::{result::Error, *};
6 mod_remove_post_view (id) {
10 reason -> Nullable<Text>,
11 removed -> Nullable<Bool>,
13 mod_user_name -> Varchar,
16 community_name -> Varchar,
20 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
21 #[table_name = "mod_remove_post_view"]
22 pub struct ModRemovePostView {
26 pub reason: Option<String>,
27 pub removed: Option<bool>,
28 pub when_: chrono::NaiveDateTime,
29 pub mod_user_name: String,
30 pub post_name: String,
31 pub community_id: i32,
32 pub community_name: String,
35 impl ModRemovePostView {
38 from_community_id: Option<i32>,
39 from_mod_user_id: Option<i32>,
42 ) -> Result<Vec<Self>, Error> {
43 use super::moderator_views::mod_remove_post_view::dsl::*;
44 let mut query = mod_remove_post_view.into_boxed();
46 let (limit, offset) = limit_and_offset(page, limit);
48 if let Some(from_community_id) = from_community_id {
49 query = query.filter(community_id.eq(from_community_id));
52 if let Some(from_mod_user_id) = from_mod_user_id {
53 query = query.filter(mod_user_id.eq(from_mod_user_id));
59 .order_by(when_.desc())
65 mod_lock_post_view (id) {
69 locked -> Nullable<Bool>,
71 mod_user_name -> Varchar,
74 community_name -> Varchar,
78 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
79 #[table_name = "mod_lock_post_view"]
80 pub struct ModLockPostView {
84 pub locked: Option<bool>,
85 pub when_: chrono::NaiveDateTime,
86 pub mod_user_name: String,
87 pub post_name: String,
88 pub community_id: i32,
89 pub community_name: String,
92 impl ModLockPostView {
95 from_community_id: Option<i32>,
96 from_mod_user_id: Option<i32>,
99 ) -> Result<Vec<Self>, Error> {
100 use super::moderator_views::mod_lock_post_view::dsl::*;
101 let mut query = mod_lock_post_view.into_boxed();
103 let (limit, offset) = limit_and_offset(page, limit);
105 if let Some(from_community_id) = from_community_id {
106 query = query.filter(community_id.eq(from_community_id));
109 if let Some(from_mod_user_id) = from_mod_user_id {
110 query = query.filter(mod_user_id.eq(from_mod_user_id));
116 .order_by(when_.desc())
122 mod_sticky_post_view (id) {
126 stickied -> Nullable<Bool>,
128 mod_user_name -> Varchar,
129 post_name -> Varchar,
130 community_id -> Int4,
131 community_name -> Varchar,
135 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
136 #[table_name = "mod_sticky_post_view"]
137 pub struct ModStickyPostView {
139 pub mod_user_id: i32,
141 pub stickied: Option<bool>,
142 pub when_: chrono::NaiveDateTime,
143 pub mod_user_name: String,
144 pub post_name: String,
145 pub community_id: i32,
146 pub community_name: String,
149 impl ModStickyPostView {
152 from_community_id: Option<i32>,
153 from_mod_user_id: Option<i32>,
156 ) -> Result<Vec<Self>, Error> {
157 use super::moderator_views::mod_sticky_post_view::dsl::*;
158 let mut query = mod_sticky_post_view.into_boxed();
160 let (limit, offset) = limit_and_offset(page, limit);
162 if let Some(from_community_id) = from_community_id {
163 query = query.filter(community_id.eq(from_community_id));
166 if let Some(from_mod_user_id) = from_mod_user_id {
167 query = query.filter(mod_user_id.eq(from_mod_user_id));
173 .order_by(when_.desc())
179 mod_remove_comment_view (id) {
183 reason -> Nullable<Text>,
184 removed -> Nullable<Bool>,
186 mod_user_name -> Varchar,
187 comment_user_id -> Int4,
188 comment_user_name -> Varchar,
189 comment_content -> Text,
191 post_name -> Varchar,
192 community_id -> Int4,
193 community_name -> Varchar,
197 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
198 #[table_name = "mod_remove_comment_view"]
199 pub struct ModRemoveCommentView {
201 pub mod_user_id: i32,
203 pub reason: Option<String>,
204 pub removed: Option<bool>,
205 pub when_: chrono::NaiveDateTime,
206 pub mod_user_name: String,
207 pub comment_user_id: i32,
208 pub comment_user_name: String,
209 pub comment_content: String,
211 pub post_name: String,
212 pub community_id: i32,
213 pub community_name: String,
216 impl ModRemoveCommentView {
219 from_community_id: Option<i32>,
220 from_mod_user_id: Option<i32>,
223 ) -> Result<Vec<Self>, Error> {
224 use super::moderator_views::mod_remove_comment_view::dsl::*;
225 let mut query = mod_remove_comment_view.into_boxed();
227 let (limit, offset) = limit_and_offset(page, limit);
229 if let Some(from_community_id) = from_community_id {
230 query = query.filter(community_id.eq(from_community_id));
233 if let Some(from_mod_user_id) = from_mod_user_id {
234 query = query.filter(mod_user_id.eq(from_mod_user_id));
240 .order_by(when_.desc())
246 mod_remove_community_view (id) {
249 community_id -> Int4,
250 reason -> Nullable<Text>,
251 removed -> Nullable<Bool>,
252 expires -> Nullable<Timestamp>,
254 mod_user_name -> Varchar,
255 community_name -> Varchar,
259 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
260 #[table_name = "mod_remove_community_view"]
261 pub struct ModRemoveCommunityView {
263 pub mod_user_id: i32,
264 pub community_id: i32,
265 pub reason: Option<String>,
266 pub removed: Option<bool>,
267 pub expires: Option<chrono::NaiveDateTime>,
268 pub when_: chrono::NaiveDateTime,
269 pub mod_user_name: String,
270 pub community_name: String,
273 impl ModRemoveCommunityView {
276 from_mod_user_id: Option<i32>,
279 ) -> Result<Vec<Self>, Error> {
280 use super::moderator_views::mod_remove_community_view::dsl::*;
281 let mut query = mod_remove_community_view.into_boxed();
283 let (limit, offset) = limit_and_offset(page, limit);
285 if let Some(from_mod_user_id) = from_mod_user_id {
286 query = query.filter(mod_user_id.eq(from_mod_user_id));
292 .order_by(when_.desc())
298 mod_ban_from_community_view (id) {
301 other_user_id -> Int4,
302 community_id -> Int4,
303 reason -> Nullable<Text>,
304 banned -> Nullable<Bool>,
305 expires -> Nullable<Timestamp>,
307 mod_user_name -> Varchar,
308 other_user_name -> Varchar,
309 community_name -> Varchar,
313 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
314 #[table_name = "mod_ban_from_community_view"]
315 pub struct ModBanFromCommunityView {
317 pub mod_user_id: i32,
318 pub other_user_id: i32,
319 pub community_id: i32,
320 pub reason: Option<String>,
321 pub banned: Option<bool>,
322 pub expires: Option<chrono::NaiveDateTime>,
323 pub when_: chrono::NaiveDateTime,
324 pub mod_user_name: String,
325 pub other_user_name: String,
326 pub community_name: String,
329 impl ModBanFromCommunityView {
332 from_community_id: Option<i32>,
333 from_mod_user_id: Option<i32>,
336 ) -> Result<Vec<Self>, Error> {
337 use super::moderator_views::mod_ban_from_community_view::dsl::*;
338 let mut query = mod_ban_from_community_view.into_boxed();
340 let (limit, offset) = limit_and_offset(page, limit);
342 if let Some(from_community_id) = from_community_id {
343 query = query.filter(community_id.eq(from_community_id));
346 if let Some(from_mod_user_id) = from_mod_user_id {
347 query = query.filter(mod_user_id.eq(from_mod_user_id));
353 .order_by(when_.desc())
362 other_user_id -> Int4,
363 reason -> Nullable<Text>,
364 banned -> Nullable<Bool>,
365 expires -> Nullable<Timestamp>,
367 mod_user_name -> Varchar,
368 other_user_name -> Varchar,
372 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
373 #[table_name = "mod_ban_view"]
374 pub struct ModBanView {
376 pub mod_user_id: i32,
377 pub other_user_id: i32,
378 pub reason: Option<String>,
379 pub banned: Option<bool>,
380 pub expires: Option<chrono::NaiveDateTime>,
381 pub when_: chrono::NaiveDateTime,
382 pub mod_user_name: String,
383 pub other_user_name: String,
389 from_mod_user_id: Option<i32>,
392 ) -> Result<Vec<Self>, Error> {
393 use super::moderator_views::mod_ban_view::dsl::*;
394 let mut query = mod_ban_view.into_boxed();
396 let (limit, offset) = limit_and_offset(page, limit);
398 if let Some(from_mod_user_id) = from_mod_user_id {
399 query = query.filter(mod_user_id.eq(from_mod_user_id));
405 .order_by(when_.desc())
411 mod_add_community_view (id) {
414 other_user_id -> Int4,
415 community_id -> Int4,
416 removed -> Nullable<Bool>,
418 mod_user_name -> Varchar,
419 other_user_name -> Varchar,
420 community_name -> Varchar,
424 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
425 #[table_name = "mod_add_community_view"]
426 pub struct ModAddCommunityView {
428 pub mod_user_id: i32,
429 pub other_user_id: i32,
430 pub community_id: i32,
431 pub removed: Option<bool>,
432 pub when_: chrono::NaiveDateTime,
433 pub mod_user_name: String,
434 pub other_user_name: String,
435 pub community_name: String,
438 impl ModAddCommunityView {
441 from_community_id: Option<i32>,
442 from_mod_user_id: Option<i32>,
445 ) -> Result<Vec<Self>, Error> {
446 use super::moderator_views::mod_add_community_view::dsl::*;
447 let mut query = mod_add_community_view.into_boxed();
449 let (limit, offset) = limit_and_offset(page, limit);
451 if let Some(from_community_id) = from_community_id {
452 query = query.filter(community_id.eq(from_community_id));
455 if let Some(from_mod_user_id) = from_mod_user_id {
456 query = query.filter(mod_user_id.eq(from_mod_user_id));
462 .order_by(when_.desc())
471 other_user_id -> Int4,
472 removed -> Nullable<Bool>,
474 mod_user_name -> Varchar,
475 other_user_name -> Varchar,
479 #[derive(Queryable, Identifiable, PartialEq, Debug, Serialize, QueryableByName, Clone)]
480 #[table_name = "mod_add_view"]
481 pub struct ModAddView {
483 pub mod_user_id: i32,
484 pub other_user_id: i32,
485 pub removed: Option<bool>,
486 pub when_: chrono::NaiveDateTime,
487 pub mod_user_name: String,
488 pub other_user_name: String,
494 from_mod_user_id: Option<i32>,
497 ) -> Result<Vec<Self>, Error> {
498 use super::moderator_views::mod_add_view::dsl::*;
499 let mut query = mod_add_view.into_boxed();
501 let (limit, offset) = limit_and_offset(page, limit);
503 if let Some(from_mod_user_id) = from_mod_user_id {
504 query = query.filter(mod_user_id.eq(from_mod_user_id));
510 .order_by(when_.desc())