summaryrefslogtreecommitdiff
path: root/src/weather_thresholds.rs
diff options
context:
space:
mode:
authorDawid Rycerz <dawid@rycerz.xyz>2025-07-16 23:03:40 +0300
committerDawid Rycerz <dawid@rycerz.xyz>2025-07-16 23:03:40 +0300
commit1aee0b802cad9fc9343b6c2966ba112f9b762f7c (patch)
tree53d9551fbfd3df01ac61ecd1128060a9a9727a84 /src/weather_thresholds.rs
parentdbb25297da61fe393ca1e8a6b6c6beace2513e0a (diff)
feat: refactor and remove lib usage
Diffstat (limited to 'src/weather_thresholds.rs')
-rw-r--r--src/weather_thresholds.rs30
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(