Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderStorm committed Aug 4, 2024
1 parent e137bd0 commit 2835c9e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 5 deletions.
55 changes: 51 additions & 4 deletions server/src/locations/details.rs
Original file line number Diff line number Diff line change
@@ -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<DateTime<Utc>>,
pub calendar_url: Option<String>,
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<String>,
pub room_key: Option<String>,
pub adress: Option<String>,
pub level: Option<String>,
pub arch_name: Option<String>,
pub room_cnt: Option<String>,
pub building_cnt: Option<String>,
}

#[get("/{id}")]
pub async fn get_handler(
Expand All @@ -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
};
Expand Down
1 change: 0 additions & 1 deletion server/src/models.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use serde::{Deserialize, Serialize};

#[derive(Debug, Clone)]
#[allow(dead_code)] // false positive. Clippy can't detect this due to macros
Expand Down

0 comments on commit 2835c9e

Please sign in to comment.