diff --git a/astroplant-api/src/models/kit.rs b/astroplant-api/src/models/kit.rs index 1978651..4064a6b 100644 --- a/astroplant-api/src/models/kit.rs +++ b/astroplant-api/src/models/kit.rs @@ -23,6 +23,8 @@ pub struct Kit { pub longitude: Option, pub privacy_public_dashboard: bool, pub privacy_show_on_map: bool, + pub created_at: DateTime, + pub updated_at: DateTime, } #[derive(Clone, Debug, PartialEq, Queryable, Identifiable, Associations)] diff --git a/astroplant-api/src/models/kit_configuration.rs b/astroplant-api/src/models/kit_configuration.rs index 1f2876b..4368087 100644 --- a/astroplant-api/src/models/kit_configuration.rs +++ b/astroplant-api/src/models/kit_configuration.rs @@ -1,10 +1,11 @@ -use crate::schema::kit_configurations; - +use chrono::{DateTime, Utc}; use diesel::pg::PgConnection; use diesel::prelude::*; use diesel::{Identifiable, QueryResult, Queryable}; use serde_json::json; +use crate::schema::kit_configurations; + use super::{Kit, KitId}; #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, Identifiable)] @@ -31,7 +32,10 @@ pub struct KitConfiguration { pub controller_symbol: String, pub control_rules: serde_json::Value, pub active: bool, + pub first_activated_at: Option>, pub never_used: bool, + pub created_at: DateTime, + pub updated_at: DateTime, } #[derive(Clone, Debug, PartialEq, Queryable, Identifiable, AsChangeset)] diff --git a/astroplant-api/src/models/user.rs b/astroplant-api/src/models/user.rs index 06317ae..835ab08 100644 --- a/astroplant-api/src/models/user.rs +++ b/astroplant-api/src/models/user.rs @@ -1,5 +1,6 @@ use crate::schema::users; +use chrono::{DateTime, Utc}; use diesel::pg::PgConnection; use diesel::prelude::*; use diesel::{Connection, Identifiable, QueryResult, Queryable}; @@ -18,6 +19,8 @@ pub struct User { pub email_address: String, pub use_email_address_for_gravatar: bool, pub gravatar_alternative: String, + pub created_at: DateTime, + pub updated_at: DateTime, } impl User { @@ -32,7 +35,10 @@ impl User { .optional() } - pub fn by_email_address(conn: &mut PgConnection, email_address: &str) -> QueryResult> { + pub fn by_email_address( + conn: &mut PgConnection, + email_address: &str, + ) -> QueryResult> { users::table .filter(users::email_address.ilike(email_address)) .first(conn) diff --git a/astroplant-api/src/schema.rs b/astroplant-api/src/schema.rs index 6e53da6..4a39de1 100644 --- a/astroplant-api/src/schema.rs +++ b/astroplant-api/src/schema.rs @@ -103,12 +103,30 @@ diesel::table! { /// /// (Automatically generated by Diesel.) active -> Bool, + /// The `first_activated_at` column of the `kit_configurations` table. + /// + /// Its SQL type is `Nullable`. + /// + /// (Automatically generated by Diesel.) + first_activated_at -> Nullable, /// The `never_used` column of the `kit_configurations` table. /// /// Its SQL type is `Bool`. /// /// (Automatically generated by Diesel.) never_used -> Bool, + /// The `created_at` column of the `kit_configurations` table. + /// + /// Its SQL type is `Timestamptz`. + /// + /// (Automatically generated by Diesel.) + created_at -> Timestamptz, + /// The `updated_at` column of the `kit_configurations` table. + /// + /// Its SQL type is `Timestamptz`. + /// + /// (Automatically generated by Diesel.) + updated_at -> Timestamptz, } } @@ -238,6 +256,18 @@ diesel::table! { /// /// (Automatically generated by Diesel.) privacy_show_on_map -> Bool, + /// The `created_at` column of the `kits` table. + /// + /// Its SQL type is `Timestamptz`. + /// + /// (Automatically generated by Diesel.) + created_at -> Timestamptz, + /// The `updated_at` column of the `kits` table. + /// + /// Its SQL type is `Timestamptz`. + /// + /// (Automatically generated by Diesel.) + updated_at -> Timestamptz, } } @@ -617,6 +647,18 @@ diesel::table! { /// (Automatically generated by Diesel.) #[max_length = 255] gravatar_alternative -> Varchar, + /// The `created_at` column of the `users` table. + /// + /// Its SQL type is `Timestamptz`. + /// + /// (Automatically generated by Diesel.) + created_at -> Timestamptz, + /// The `updated_at` column of the `users` table. + /// + /// Its SQL type is `Timestamptz`. + /// + /// (Automatically generated by Diesel.) + updated_at -> Timestamptz, } } diff --git a/astroplant-api/src/views.rs b/astroplant-api/src/views.rs index d1ade34..cc35aee 100644 --- a/astroplant-api/src/views.rs +++ b/astroplant-api/src/views.rs @@ -316,6 +316,7 @@ impl From for KitConfiguration { control_rules, active, never_used, + .. }: models::KitConfiguration, ) -> Self { Self {