|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- use diesel::sql_types::Integer;
- use diesel::sql_types::Nullable;
- use diesel::sql_types::SmallInt;
- use diesel::sql_types::Timestamp;
- use diesel::sql_types::Text;
- use diesel::sql_types::BigInt;
- use chrono::NaiveDateTime;
- use diesel::{Insertable, Queryable, QueryableByName, Selectable};
- use serde::Serialize;
-
- #[derive(Queryable, Selectable, Serialize, Clone)]
- #[diesel(table_name = crate::schema::issues)]
- #[diesel(check_for_backend(diesel::pg::Pg))]
- pub struct Issue {
- pub id: i32,
- pub title: String,
- pub paragraph_count: Option<i16>,
- pub telegram_handle: String,
- pub created_at: Option<NaiveDateTime>
- }
-
- #[derive(QueryableByName, Serialize, Clone)]
- pub struct IssueWithSummaryAndVotes {
- #[diesel(sql_type = Integer)]
- pub id: i32,
- #[diesel(sql_type = Text)]
- pub title: String,
- #[diesel(sql_type = Text)]
- pub summary: String,
- #[diesel(sql_type = Nullable<SmallInt>)]
- pub paragraph_count: Option<i16>,
- #[diesel(sql_type = Text)]
- pub telegram_handle: String,
- #[diesel(sql_type = Nullable<Timestamp>)]
- pub created_at: Option<NaiveDateTime>,
- #[diesel(sql_type = BigInt)]
- pub total_votes: i64,
- #[diesel(sql_type = BigInt)]
- pub positive_votes: i64,
- }
-
- #[derive(Insertable)]
- #[diesel(table_name = crate::schema::issues)]
- pub struct NewIssue {
- pub title: String,
- pub paragraph_count: i16,
- pub telegram_handle: String,
- }
-
- #[derive(Queryable, Selectable)]
- #[diesel(table_name = crate::schema::sessions)]
- #[diesel(check_for_backend(diesel::pg::Pg))]
- pub struct Session {
- pub id: i64,
- pub session_id: String,
- pub auth_date: Option<i64>,
- pub username: Option<String>,
- pub first_name: Option<String>,
- pub last_name: Option<String>,
- pub photo_url: Option<String>
- }
-
- #[derive(Insertable)]
- #[diesel(table_name = crate::schema::sessions)]
- pub struct NewSession {
- pub user_id: Option<i64>,
- pub session_id: String,
- pub auth_date: i64,
- pub username: Option<String>,
- pub first_name: Option<String>,
- pub last_name: Option<String>,
- pub photo_url: Option<String>
- }
-
- #[derive(Queryable, Selectable, Serialize, Clone)]
- #[diesel(table_name = crate::schema::paragraphs)]
- #[diesel(check_for_backend(diesel::pg::Pg))]
- pub struct Paragraph {
- pub id: i64,
- pub content: String,
- pub index: i32,
- pub post_id: i32,
- }
-
- #[derive(Insertable)]
- #[diesel(table_name = crate::schema::paragraphs)]
- pub struct NewParagraph {
- pub content: Option<String>,
- pub index: i32,
- pub post_id: i32,
- }
-
- #[derive(Queryable, Selectable, Serialize, Clone)]
- #[diesel(table_name = crate::schema::issue_votes)]
- #[diesel(check_for_backend(diesel::pg::Pg))]
- pub struct IssueVote {
- pub id: i64,
- pub positive: Option<bool>,
- pub issue_id: i32,
- pub user_id: i64,
- }
-
- #[derive(Insertable)]
- #[diesel(table_name = crate::schema::issue_votes)]
- pub struct NewIssueVote {
- pub positive: bool,
- pub issue_id: i32,
- pub user_id: i64,
- }
-
- #[derive(Queryable, Selectable, Serialize, Clone)]
- #[diesel(table_name = crate::schema::comments)]
- #[diesel(check_for_backend(diesel::pg::Pg))]
- pub struct Comment {
- pub id: i64,
- pub content: String,
- pub parent: Option<i64>,
- pub telegram_handle: String,
- pub issue_id: i32,
- pub created_at: Option<NaiveDateTime>
- }
-
- #[derive(Insertable)]
- #[diesel(table_name = crate::schema::comments)]
- pub struct NewComment {
- pub content: String,
- pub parent: Option<i64>,
- pub telegram_handle: String,
- pub issue_id: i32,
- pub created_at: NaiveDateTime
- }
-
- #[derive(Queryable, Selectable, Serialize, Clone)]
- #[diesel(table_name = crate::schema::comment_votes)]
- #[diesel(check_for_backend(diesel::pg::Pg))]
- pub struct CommentVote {
- pub id: i64,
- pub positive: Option<bool>,
- pub comment_id: i64,
- pub user_id: i64,
- }
-
- #[derive(Insertable)]
- #[diesel(table_name = crate::schema::comment_votes)]
- pub struct NewCommentVote {
- pub positive: Option<bool>,
- pub comment_id: Option<i64>,
- pub user_id: Option<i64>,
- }
|