X-Git-Url: http://git.euphorik.ch/?p=recipes.git;a=blobdiff_plain;f=backend%2Fsrc%2Fmain.rs;fp=backend%2Fsrc%2Fmain.rs;h=1fbfbc53e357fd319bd3a50c964a81ea8ef369eb;hp=5c6de4c462fa1504d06626686affc1cca2a28ee7;hb=5e4e0862477f46a6ea477a56f01fd84e720a9546;hpb=855eb169737848e21061e637a8d562ccc33c58e8 diff --git a/backend/src/main.rs b/backend/src/main.rs index 5c6de4c..1fbfbc5 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -4,13 +4,15 @@ use std::sync::Mutex; use actix_files as fs; use actix_web::{get, web, Responder, middleware, App, HttpServer, HttpRequest}; use askama_actix::Template; +use chrono::prelude::*; use clap::Parser; use ron::de::from_reader; use serde::Deserialize; mod consts; -mod model; mod db; +mod hash; +mod model; #[derive(Template)] #[template(path = "home.html")] @@ -98,16 +100,26 @@ async fn main() -> std::io::Result<()> { #[derive(Parser, Debug)] struct Args { #[arg(long)] - test: bool + dbtest: bool } fn process_args() -> bool { let args = Args::parse(); - if args.test { - if let Err(error) = db::Connection::new() { - println!("Error: {:?}", error) + if args.dbtest { + match db::Connection::new() { + Ok(con) => { + if let Err(error) = con.execute_file("sql/data_test.sql") { + println!("Error: {:?}", error); + } + // Set the creation datetime to 'now'. + con.execute_sql("UPDATE [User] SET [creation_datetime] = ?1 WHERE [email] = 'paul@test.org'", [Utc::now()]).unwrap(); + }, + Err(error) => { + println!("Error: {:?}", error) + }, } + return true; }