optimize query
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Failing after 6m2s
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Failing after 6m2s
This commit is contained in:
parent
0593f14408
commit
775d6c2899
2 changed files with 7 additions and 5 deletions
|
|
@ -54,14 +54,14 @@ async fn get_route_info(route_id: String, state: Data<Arc<AppState>>) -> ::anyho
|
|||
let mut tx = state.database.begin().await?;
|
||||
|
||||
let route = database::get_route_by_id(route_id.clone(), &mut tx).await?;
|
||||
//let directions = database::get_direction_by_route_id(route_id.clone(), &mut tx).await?;
|
||||
let directions = database::get_direction_by_route_id(route_id.clone(), &mut tx).await?;
|
||||
let mut trips = database::get_schedule_by_route_id(route_id.clone(), &mut tx).await?;
|
||||
|
||||
state.trip_tracking_service.annotate_trips(&mut trips);
|
||||
|
||||
Ok(RouteResponse{
|
||||
route,
|
||||
directions: Vec::new(),
|
||||
directions,
|
||||
schedule: trips
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ pub async fn get_schedule_by_route_id(
|
|||
septa_stop_schedules.route_id,
|
||||
septa_stops.name as stop_name,
|
||||
trip_id,
|
||||
service_id,
|
||||
septa_stop_schedules.service_id,
|
||||
septa_stop_schedules.direction_id,
|
||||
arrival_time,
|
||||
stop_id,
|
||||
|
|
@ -129,10 +129,12 @@ pub async fn get_schedule_by_route_id(
|
|||
septa_stop_schedules
|
||||
INNER JOIN septa_stops
|
||||
ON septa_stops.id = septa_stop_schedules.stop_id
|
||||
INNER JOIN septa_schedule_days
|
||||
ON septa_schedule_days.date = $2
|
||||
AND
|
||||
septa_schedule_days.service_id = septa_stop_schedules.service_id
|
||||
WHERE
|
||||
septa_stop_schedules.route_id = $1
|
||||
AND
|
||||
service_id IN (SELECT service_id FROM septa_schedule_days WHERE date = $2)
|
||||
;"#,
|
||||
id.clone(),
|
||||
schedule_day_str.clone()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue