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