added parameter station to determine the location to be checked

This commit is contained in:
Ollo
2026-02-28 21:39:18 +01:00
parent eeb1668460
commit 4cad8e7202
2 changed files with 14 additions and 1 deletions

View File

@@ -34,6 +34,8 @@ struct Args {
port: u16,
#[arg(long, default_value_t = 300)]
interval: u32,
#[arg(long, default_value = "Lettestr")]
station: String,
}
@@ -53,7 +55,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
//FIXME Set last_request initially to 1 hour before now
let mut last_request = Instant::now() - Duration::from_secs(3600);
let interval = Duration::from_secs(args.interval as u64);
let station_id = tokio::task::spawn_blocking(|| straba::lookup_station_id("Lettestr"))
let station_id = tokio::task::spawn_blocking(move || straba::lookup_station_id(&args.station))
.await
.unwrap()
.expect("Failed to lookup station ID");

View File

@@ -214,6 +214,17 @@ pub fn fetch_data(station_id: u64, debug_print: Option<bool>) -> NextDeparture {
return_value.inbound_station = stop.destination_label;
return_value.inbound_diff = diff;
}
} else if stop.destination_label.contains("Mannheim") {
if diff < return_value.inbound_diff {
return_value.inbound_station = stop.destination_label;
return_value.inbound_diff = diff;
}
} else {
// Unkown stations are declared as outbound
if diff < return_value.outbound_diff {
return_value.outbound_station = stop.destination_label;
return_value.outbound_diff = diff;
}
}
} else {
println!(