use super::schema::events; use chrono::{NaiveDateTime, Utc}; #[derive(Queryable, Clone, Debug)] pub struct Event { /// Event ID pub id: i32, /// Event name pub event_name: String, /// Event long description pub event_desc: String, /// Event location pub event_loc: String, /// Event organizer pub organizer: String, /// Event datetime pub event_time: NaiveDateTime, /// Event discord message id pub message_id: String, /// Event message thumbnail link pub thumbnail_link: String, /// Reminder sent tracker pub reminder_sent: i32, } impl Into for Event { fn into(self) -> NewEvent { NewEvent { event_name: self.event_name.clone(), event_desc: self.event_desc.clone(), organizer: self.organizer.clone(), event_loc: self.event_loc.clone(), event_time: self.event_time, message_id: self.message_id.clone(), thumbnail_link: self.message_id.clone(), reminder_sent: self.reminder_sent, } } } #[derive(Insertable, Clone, Debug)] #[table_name = "events"] pub struct NewEvent { /// Event name pub event_name: String, /// Event long description pub event_desc: String, /// Event location pub event_loc: String, /// Event organizer pub organizer: String, /// Event datetime pub event_time: NaiveDateTime, /// Event discord message id pub message_id: String, /// Event message thumbnail link pub thumbnail_link: String, /// Reminder sent tracker pub reminder_sent: i32, } impl Default for NewEvent { fn default() -> Self { Self { message_id: String::default(), event_time: Utc::now().naive_utc(), event_name: String::default(), organizer: String::default(), event_desc: String::default(), event_loc: String::default(), thumbnail_link: String::default(), reminder_sent: i32::default(), } } }