diff options
Diffstat (limited to 'src/weather_thresholds.rs')
| -rw-r--r-- | src/weather_thresholds.rs | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/weather_thresholds.rs b/src/weather_thresholds.rs index 36237df..ed95f13 100644 --- a/src/weather_thresholds.rs +++ b/src/weather_thresholds.rs @@ -1,12 +1,5 @@ -use crate::auth::AuthUser; -use axum::Json; -use axum::extract::{Query, State}; -use axum::http::StatusCode; -use axum::response::IntoResponse; use serde::{Deserialize, Serialize}; use sqlx::FromRow; -use std::collections::HashMap; -use std::sync::Arc; #[derive(Debug, Serialize, Deserialize, FromRow, Clone, PartialEq)] pub struct WeatherThreshold { @@ -110,27 +103,6 @@ impl<'a> WeatherThresholdRepository<'a> { } } -pub async fn list_thresholds( - AuthUser(_): AuthUser, - State(pool): State<Arc<sqlx::SqlitePool>>, - Query(query): Query<HashMap<String, String>>, -) -> impl IntoResponse { - let repo = WeatherThresholdRepository { db: &pool }; - let user_id = match query.get("user_id").and_then(|s| s.parse().ok()) { - Some(uid) => uid, - None => { - return crate::error_response( - StatusCode::BAD_REQUEST, - "user_id required as query param", - ); - } - }; - match repo.list_thresholds(user_id).await { - Ok(thresholds) => Json(thresholds).into_response(), - Err(e) => crate::error_response(StatusCode::INTERNAL_SERVER_ERROR, &e.to_string()), - } -} - #[cfg(test)] mod tests { use super::*; @@ -138,8 +110,6 @@ mod tests { use sqlx::{Executor, SqlitePool}; - use tokio; - async fn setup_db() -> SqlitePool { let pool = SqlitePool::connect(":memory:").await.unwrap(); pool.execute( |
