fixed db queries
Some checks failed
Create and publish a Docker image / build-and-push-image (push) Failing after 19m27s

This commit is contained in:
Nicholas Orlowsky 2025-09-14 11:38:35 -04:00
parent 38d9daea3f
commit 0cda7295be
No known key found for this signature in database
GPG key ID: A9F3BA4C0AA7A70B

View file

@ -97,6 +97,9 @@ pub async fn get_schedule_by_route_id(
transaction: &mut Transaction<'_, Postgres>, transaction: &mut Transaction<'_, Postgres>,
) -> ::anyhow::Result<Vec<Trip>> { ) -> ::anyhow::Result<Vec<Trip>> {
let schedule_day = chrono::Utc::now().with_timezone(&chrono_tz::America::New_York);
let schedule_day_str = schedule_day.format("YYYYMMDD").to_string();
let rows = sqlx::query!( let rows = sqlx::query!(
r#"SELECT r#"SELECT
septa_stop_schedules.route_id, septa_stop_schedules.route_id,
@ -120,9 +123,10 @@ pub async fn get_schedule_by_route_id(
WHERE WHERE
septa_stop_schedules.route_id = $1 septa_stop_schedules.route_id = $1
AND AND
service_id IN (SELECT service_id FROM septa_schedule_days WHERE date = '20250707') service_id IN (SELECT service_id FROM septa_schedule_days WHERE date = $2)
;"#, ;"#,
id id,
schedule_day_str
) )
.fetch_all(&mut **transaction) .fetch_all(&mut **transaction)
.await?; .await?;
@ -223,6 +227,9 @@ pub async fn get_nta_by_stop_id(
let start_secs = local_start.signed_duration_since(local_midnight).num_seconds(); let start_secs = local_start.signed_duration_since(local_midnight).num_seconds();
let end_secs = local_end.signed_duration_since(local_midnight).num_seconds(); let end_secs = local_end.signed_duration_since(local_midnight).num_seconds();
let schedule_day = chrono::Utc::now().with_timezone(&chrono_tz::America::New_York);
let schedule_day_str = schedule_day.format("YYYYMMDD").to_string();
let name_row = sqlx::query!("SELECT name FROM septa_stops WHERE id = $1", ids[0]).fetch_one(&mut **transaction).await?; let name_row = sqlx::query!("SELECT name FROM septa_stops WHERE id = $1", ids[0]).fetch_one(&mut **transaction).await?;
let stop_name = name_row.name; let stop_name = name_row.name;
@ -251,7 +258,7 @@ pub async fn get_nta_by_stop_id(
WHERE WHERE
(septa_stops.id = $1 OR septa_stops.id = $2) (septa_stops.id = $1 OR septa_stops.id = $2)
AND AND
service_id IN (SELECT service_id FROM septa_schedule_days WHERE date = '20250707') service_id IN (SELECT service_id FROM septa_schedule_days WHERE date = $5)
AND AND
septa_stop_schedules.arrival_time > $3 septa_stop_schedules.arrival_time > $3
AND AND
@ -262,6 +269,7 @@ pub async fn get_nta_by_stop_id(
.bind(&ids.get(1).unwrap_or(&0)) .bind(&ids.get(1).unwrap_or(&0))
.bind(&start_secs) .bind(&start_secs)
.bind(&end_secs) .bind(&end_secs)
.bind(&schedule_day_str)
.fetch_all(&mut **transaction) .fetch_all(&mut **transaction)
.await?; .await?;