diff --git a/src/db.rs b/src/db.rs index a7cd35d..be0cdaa 100644 --- a/src/db.rs +++ b/src/db.rs @@ -1,6 +1,6 @@ use crate::data::{Game, Player, Team}; use actix_web::{Error, error, web}; -use rusqlite::{Row, params}; +use rusqlite::Row; use serde_json::{Map, Value}; use std::collections::HashMap; @@ -14,18 +14,6 @@ const GAMES_QUERY: &str = const TEAMS_QUERY: &str = "select game, team, min(color), group_concat(player) from teams group by game, team"; -pub async fn execute_query(pool: &Pool, query: &str) -> Result { - let pool = pool.clone(); - let conn = web::block(move || pool.get()) - .await? - .map_err(error::ErrorInternalServerError)?; - match conn.execute(query, params![]) { - Ok(val) => println!("{val:?}"), - Err(er) => println!("error: {er:?}"), - } - Ok(String::from("success")) -} - pub async fn execute_stmt(pool: &Pool, query: &str) -> Result { let pool = pool.clone(); let conn = web::block(move || pool.get()) diff --git a/src/main.rs b/src/main.rs index 569ee63..952b127 100644 --- a/src/main.rs +++ b/src/main.rs @@ -65,7 +65,6 @@ struct GamesActor { #[derive(Deserialize, Debug)] struct QueryForm { query: String, - is_read: bool, } impl Actor for GamesActor { @@ -181,11 +180,7 @@ async fn list_of_games(games: web::Data>>>) -> impl Responde #[post("/admin/query")] async fn admin_query(pool: web::Data, form: web::Form) -> impl Responder { let res: String; - if form.is_read { - res = db::execute_stmt(&pool, &form.query).await.unwrap(); - } else { - res = db::execute_query(&pool, &form.query).await.unwrap(); - } + res = db::execute_stmt(&pool, &form.query).await.unwrap(); HttpResponse::Ok() .content_type("application/json") .body(res) diff --git a/src/templates/admin.tera b/src/templates/admin.tera index 5c945a6..96c707a 100644 --- a/src/templates/admin.tera +++ b/src/templates/admin.tera @@ -76,7 +76,6 @@ method: "POST", body: new URLSearchParams({ 'query': document.getElementById("query").value, - 'is_read': true, }) }) .then(res => {