add load time and autofocus
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Failing after 10m5s
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Failing after 10m5s
This commit is contained in:
parent
917428507d
commit
5539c8521d
10 changed files with 153 additions and 11 deletions
|
|
@ -134,7 +134,7 @@ pub async fn get_schedule_by_route_id(
|
|||
AND
|
||||
septa_schedule_days.service_id = septa_stop_schedules.service_id
|
||||
WHERE
|
||||
septa_stop_schedules.route_id = $1
|
||||
septa_stop_schedules.route_id = $1 OR septa_stop_schedules.route_id = 'B2'
|
||||
;"#,
|
||||
id.clone(),
|
||||
schedule_day_str.clone()
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ use libseptastic::{direction::Direction, stop_schedule::{Trip, TripTracking}};
|
|||
use std::{cmp::Ordering, collections::BTreeMap};
|
||||
use serde::{Serialize};
|
||||
use libseptastic::stop_schedule::TripTracking::Tracked;
|
||||
use chrono::Timelike;
|
||||
|
||||
#[derive(askama::Template)]
|
||||
#[template(path = "layout.html")]
|
||||
|
|
@ -49,9 +50,11 @@ pub struct TimetableDirection {
|
|||
pub direction: Direction,
|
||||
pub trip_ids: Vec<String>,
|
||||
pub tracking_data: Vec<TripTracking>,
|
||||
pub rows: Vec<TimetableStopRow>
|
||||
pub rows: Vec<TimetableStopRow>,
|
||||
pub next_id: Option<String>
|
||||
}
|
||||
|
||||
|
||||
pub fn build_timetables(
|
||||
directions: Vec<Direction>,
|
||||
trips: Vec<Trip>,
|
||||
|
|
@ -59,6 +62,12 @@ pub fn build_timetables(
|
|||
let mut results = Vec::new();
|
||||
|
||||
for direction in directions {
|
||||
let now = chrono::Local::now();
|
||||
let naive_time = now.time();
|
||||
let seconds_since_midnight = naive_time.num_seconds_from_midnight();
|
||||
|
||||
let mut next_id: Option<String> = None;
|
||||
|
||||
let mut direction_trips: Vec<&Trip> = trips
|
||||
.iter()
|
||||
.filter(|trip| trip.direction_id == direction.direction_id)
|
||||
|
|
@ -72,6 +81,14 @@ pub fn build_timetables(
|
|||
.unwrap_or(i64::MAX)
|
||||
});
|
||||
|
||||
for trip in direction_trips.clone() {
|
||||
if let Some(last) = trip.schedule.last() {
|
||||
if next_id == None && i64::from(seconds_since_midnight) < last.arrival_time {
|
||||
next_id = Some(last.trip_id.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let trip_ids: Vec<String> = direction_trips
|
||||
.iter()
|
||||
.map(|t| t.trip_id.clone())
|
||||
|
|
@ -120,7 +137,8 @@ pub fn build_timetables(
|
|||
direction: direction.clone(),
|
||||
trip_ids,
|
||||
rows,
|
||||
tracking_data: live_trips
|
||||
tracking_data: live_trips ,
|
||||
next_id
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue