Skip to content

Commit 2835c9e

Browse files
tmp
1 parent e137bd0 commit 2835c9e

File tree

2 files changed

+51
-5
lines changed

2 files changed

+51
-5
lines changed

server/src/locations/details.rs

+51-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,57 @@
1+
use crate::localisation;
2+
use crate::models::LocationKeyAlias;
13
use actix_web::{get, web, HttpResponse};
4+
use chrono::DateTime;
5+
use chrono::Utc;
26
use sqlx::Error::RowNotFound;
37
use sqlx::PgPool;
48
use tracing::error;
9+
use serde::{Deserialize, Serialize};
510

6-
use crate::localisation;
7-
use crate::models::LocationKeyAlias;
11+
#[derive(Debug, Clone)]
12+
pub struct Usage {
13+
id: i64,
14+
name: String,
15+
din_277: String,
16+
din_277_desc: String,
17+
}
18+
19+
#[derive(Debug, Clone)]
20+
pub struct Operator {
21+
id: String,
22+
url: String,
23+
code: String,
24+
name: String,
25+
}
26+
27+
#[derive(Debug, Clone)]
28+
pub struct Url {
29+
name: String,
30+
url: String,
31+
}
32+
33+
#[derive(Debug, Clone)]
34+
pub struct DBLocationDetails {
35+
pub key: String,
36+
pub name: String,
37+
pub last_calendar_scrape_at: Option<DateTime<Utc>>,
38+
pub calendar_url: Option<String>,
39+
pub r#type: String,
40+
pub type_common_name: String,
41+
pub lat: f64,
42+
pub lon: f64,
43+
pub coordinate_source: String,
44+
pub rank_type: String,
45+
pub rank_combined: String,
46+
pub rank_usage: String,
47+
pub comment: Option<String>,
48+
pub room_key: Option<String>,
49+
pub adress: Option<String>,
50+
pub level: Option<String>,
51+
pub arch_name: Option<String>,
52+
pub room_cnt: Option<String>,
53+
pub building_cnt: Option<String>,
54+
}
855

956
#[get("/{id}")]
1057
pub async fn get_handler(
@@ -19,11 +66,11 @@ pub async fn get_handler(
1966
return HttpResponse::NotFound().body("Not found");
2067
};
2168
let result = if args.should_use_english() {
22-
sqlx::query_scalar!("SELECT data FROM en WHERE key = $1", probable_id)
69+
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)
2370
.fetch_optional(&data.pool)
2471
.await
2572
} else {
26-
sqlx::query_scalar!("SELECT data FROM de WHERE key = $1", probable_id)
73+
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)
2774
.fetch_optional(&data.pool)
2875
.await
2976
};

server/src/models.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use serde::{Deserialize, Serialize};
21

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

0 commit comments

Comments
 (0)