diff --git a/server/src/locations/details.rs b/server/src/locations/details.rs index 5552c6ba5..fbae263a6 100644 --- a/server/src/locations/details.rs +++ b/server/src/locations/details.rs @@ -1,10 +1,57 @@ +use crate::localisation; +use crate::models::LocationKeyAlias; use actix_web::{get, web, HttpResponse}; +use chrono::DateTime; +use chrono::Utc; use sqlx::Error::RowNotFound; use sqlx::PgPool; use tracing::error; +use serde::{Deserialize, Serialize}; -use crate::localisation; -use crate::models::LocationKeyAlias; +#[derive(Debug, Clone)] +pub struct Usage { + id: i64, + name: String, + din_277: String, + din_277_desc: String, +} + +#[derive(Debug, Clone)] +pub struct Operator { + id: String, + url: String, + code: String, + name: String, +} + +#[derive(Debug, Clone)] +pub struct Url { + name: String, + url: String, +} + +#[derive(Debug, Clone)] +pub struct DBLocationDetails { + pub key: String, + pub name: String, + pub last_calendar_scrape_at: Option>, + pub calendar_url: Option, + pub r#type: String, + pub type_common_name: String, + pub lat: f64, + pub lon: f64, + pub coordinate_source: String, + pub rank_type: String, + pub rank_combined: String, + pub rank_usage: String, + pub comment: Option, + pub room_key: Option, + pub adress: Option, + pub level: Option, + pub arch_name: Option, + pub room_cnt: Option, + pub building_cnt: Option, +} #[get("/{id}")] pub async fn get_handler( @@ -19,11 +66,11 @@ pub async fn get_handler( return HttpResponse::NotFound().body("Not found"); }; let result = if args.should_use_english() { - sqlx::query_scalar!("SELECT data FROM en WHERE key = $1", probable_id) + sqlx::query_as!(DBLocationDetails,"SELECT key,name,last_calendar_scrape_at,calendar_url,type,type_common_name,lat,lon,coordinate_source,rank_type,rank_combined,rank_usage,comment,room_key,adress,level,arch_name,room_cnt,building_cnt FROM en WHERE key = $1", probable_id) .fetch_optional(&data.pool) .await } else { - sqlx::query_scalar!("SELECT data FROM de WHERE key = $1", probable_id) + sqlx::query_as!(DBLocationDetails,"SELECT key,name,last_calendar_scrape_at,calendar_url,type,type_common_name,lat,lon,coordinate_source,rank_type,rank_combined,rank_usage,comment,room_key,adress,level,arch_name,room_cnt,building_cnt FROM de WHERE key = $1", probable_id) .fetch_optional(&data.pool) .await }; diff --git a/server/src/models.rs b/server/src/models.rs index 7e6757a59..f8885be00 100644 --- a/server/src/models.rs +++ b/server/src/models.rs @@ -1,4 +1,3 @@ -use serde::{Deserialize, Serialize}; #[derive(Debug, Clone)] #[allow(dead_code)] // false positive. Clippy can't detect this due to macros