]> Untitled Git - lemmy.git/blob - server/src/db/site_view.rs
Merge remote-tracking branch 'upstream/master'
[lemmy.git] / server / src / db / site_view.rs
1 use super::*;
2
3 table! {
4   site_view (id) {
5     id -> Int4,
6     name -> Varchar,
7     description -> Nullable<Text>,
8     creator_id -> Int4,
9     published -> Timestamp,
10     updated -> Nullable<Timestamp>,
11     enable_downvotes -> Bool,
12     open_registration -> Bool,
13     enable_nsfw -> Bool,
14     creator_name -> Varchar,
15     creator_avatar -> Nullable<Text>,
16     number_of_users -> BigInt,
17     number_of_posts -> BigInt,
18     number_of_comments -> BigInt,
19     number_of_communities -> BigInt,
20   }
21 }
22
23 #[derive(
24   Queryable, Identifiable, PartialEq, Debug, Serialize, Deserialize, QueryableByName, Clone,
25 )]
26 #[table_name = "site_view"]
27 pub struct SiteView {
28   pub id: i32,
29   pub name: String,
30   pub description: Option<String>,
31   pub creator_id: i32,
32   pub published: chrono::NaiveDateTime,
33   pub updated: Option<chrono::NaiveDateTime>,
34   pub enable_downvotes: bool,
35   pub open_registration: bool,
36   pub enable_nsfw: bool,
37   pub creator_name: String,
38   pub creator_avatar: Option<String>,
39   pub number_of_users: i64,
40   pub number_of_posts: i64,
41   pub number_of_comments: i64,
42   pub number_of_communities: i64,
43 }
44
45 impl SiteView {
46   pub fn read(conn: &PgConnection) -> Result<Self, Error> {
47     use super::site_view::site_view::dsl::*;
48     site_view.first::<Self>(conn)
49   }
50 }