diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 1a42b15..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 09f6cb3..767e363 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target Cargo.lock /database/database.sqlite -/NEA_Screenshots \ No newline at end of file +/NEA_Screenshots +.DS_Store \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 6902199..4f32d18 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ // relevant macros and imports for rocket.rs #[macro_use] extern crate rocket; -use rocket::{Rocket, Build, fs::{FileServer, relative}, serde::{Deserialize, json::Json}}; +use rocket::{Rocket, Build, fs::{FileServer, relative}, serde::{Deserialize, json::Json}, Error, Response}; pub mod sql; #[get("/")] @@ -14,28 +14,17 @@ fn test() -> String { #[serde(crate = "rocket::serde")] struct PostTest<'r> { test_type: &'r str, - test_length: i64, - test_time: i32, + test_length: u32, + test_time: u32, test_seed: i64, quote_id: i32, - wpm: i16, - accuracy: i8, - user_id: i32 + wpm: u8, + accuracy: u8, + user_id: u32 } #[post("/post_test", data = "")] fn post_test(test: Json>) { - println!( - "{}\n{}\n{}\n{}\n{}\n{}\n{}\n{}", - test.test_type, - test.test_length, - test.test_time, - test.test_seed, - test.quote_id, - test.wpm, - test.accuracy, - test.user_id - ); sql::post_test(test.test_type, test.test_length, test.test_time, test.test_seed, test.quote_id, test.wpm, test.accuracy, test.user_id) .expect("error in posting test to tests table"); } diff --git a/src/sql.rs b/src/sql.rs index 8a3533a..05b0968 100644 --- a/src/sql.rs +++ b/src/sql.rs @@ -26,7 +26,7 @@ pub fn create_database() -> Result<()> { Ok(()) } -pub fn post_test(test_type: &str, test_length: i64, test_time: i32, test_seed: i64, quote_id: i32, wpm: i16, accuracy: i8, user_id: i32) +pub fn post_test(test_type: &str, test_length: u32, test_time: u32, test_seed: i64, quote_id: i32, wpm: u8, accuracy: u8, user_id: u32) -> Result<()> { let connection = get_connection();