From 371a647536c735118a66522fc46f86a0ec09e2d7 Mon Sep 17 00:00:00 2001 From: niliara-edu Date: Mon, 20 Jan 2025 01:34:42 +0100 Subject: just formatting --- src/main.rs | 10 ++++++---- src/routes/search_results.rs | 18 +++++++----------- 2 files changed, 13 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 8dbc7d0..2871fc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ +mod database; mod routes; mod structs; -mod database; use actix_web::{web, App, HttpServer}; use dotenv::dotenv; @@ -8,7 +8,7 @@ use std::sync::Arc; #[derive(Clone)] struct AppState { - database: Arc + database: Arc, } #[actix_web::main] @@ -19,9 +19,11 @@ async fn main() -> std::io::Result<()> { env_logger::init(); dotenv().ok(); - let db_raw = database::DatabaseWrapper::new().await.expect("Something went wrong -- DatabaseWrapper::new()"); + let db_raw = database::DatabaseWrapper::new() + .await + .expect("Something went wrong -- DatabaseWrapper::new()"); let db = Arc::new(db_raw); - let app_state = AppState{database: db}; + let app_state = AppState { database: db }; HttpServer::new(move || { App::new() diff --git a/src/routes/search_results.rs b/src/routes/search_results.rs index 03bd079..5c9efb8 100644 --- a/src/routes/search_results.rs +++ b/src/routes/search_results.rs @@ -31,20 +31,16 @@ pub async fn search_results( .search_results_by_name(&get_args.name.clone().unwrap()) .await } - _ => app_state - .database - .search_results() - .await - // Err(sqlx::Error::RowNotFound), - // Err(sqlx::Error::RowNotFound), - // Err(sqlx::Error::RowNotFound), + _ => app_state.database.search_results().await, // Err(sqlx::Error::RowNotFound), + // Err(sqlx::Error::RowNotFound), + // Err(sqlx::Error::RowNotFound), }; return HttpResponse::Ok().json(( - search_attempt.0.unwrap_or_else(|_| return Vec::new()), - search_attempt.1.unwrap_or_else(|_| return Vec::new()), - search_attempt.2.unwrap_or_else(|_| return Vec::new()) - )) + search_attempt.0.unwrap_or_else(|_| return Vec::new()), + search_attempt.1.unwrap_or_else(|_| return Vec::new()), + search_attempt.2.unwrap_or_else(|_| return Vec::new()), + )); } fn check_if_exists(value: &Option) -> bool { -- cgit v1.2.3