clean up + update dfile
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 6m0s
All checks were successful
Create and publish a Docker image / build-and-push-image (push) Successful in 6m0s
This commit is contained in:
parent
7904c80642
commit
8fd41b1090
8 changed files with 314 additions and 335 deletions
|
|
@ -6,21 +6,7 @@ use std::collections::HashMap;
|
|||
use std::time::Duration;
|
||||
use log::{error, info};
|
||||
use serde::{Serialize, Deserialize, Deserializer};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum TripTracking {
|
||||
Tracked(LiveTrip),
|
||||
Untracked,
|
||||
Cancelled
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct LiveTrip {
|
||||
pub delay: f64,
|
||||
pub next_stop_id: Option<String>,
|
||||
pub timestamp: i64,
|
||||
pub vehicle_id: Option<String>
|
||||
}
|
||||
use libseptastic::stop_schedule::{LiveTrip, TripTracking};
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct LiveTripJson {
|
||||
|
|
@ -71,8 +57,6 @@ impl TripTrackingService {
|
|||
let cloned_state = Arc::clone(&self.state);
|
||||
thread::spawn( move || {
|
||||
loop {
|
||||
info!("started");
|
||||
|
||||
let clonedx_state = Arc::clone(&cloned_state);
|
||||
let res = Self::update_live_trips(clonedx_state);
|
||||
|
||||
|
|
@ -88,7 +72,7 @@ impl TripTrackingService {
|
|||
});
|
||||
}
|
||||
|
||||
pub fn annotate_trips(&self, trips: &mut Vec<crate::database::Trip>) {
|
||||
pub fn annotate_trips(&self, trips: &mut Vec<libseptastic::stop_schedule::Trip>) {
|
||||
for trip in trips {
|
||||
trip.tracking_data = match self.state.lock().unwrap().tracking_data.get(&trip.trip_id.clone()){
|
||||
Some(x) => x.clone(),
|
||||
|
|
@ -128,7 +112,6 @@ impl TripTrackingService {
|
|||
);
|
||||
}
|
||||
|
||||
info!("populated tracking data with {} entries", new_map.len());
|
||||
(service.lock().unwrap()).tracking_data = new_map;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue