diff --git a/src/birch/nearby_departures.rs b/src/birch/nearby_departures.rs index 63d5219..211a672 100644 --- a/src/birch/nearby_departures.rs +++ b/src/birch/nearby_departures.rs @@ -190,198 +190,6 @@ pub struct DepartingTripsDataAnswer { pub stop: HashMap>, } -#[actix_web::get("/departurefromstop")] -pub async fn departures_from_stop( - req: HttpRequest, - query: Query, - etcd_connection_ips: web::Data>, - sqlx_pool: web::Data>>, - pool: web::Data>, - etcd_connection_options: web::Data>>, -) -> impl Responder { - let mut etcd = etcd_client::Client::connect( - etcd_connection_ips.ip_addresses.as_slice(), - etcd_connection_options.as_ref().as_ref().to_owned(), - ) - .await - .unwrap(); - - let conn_pool = pool.as_ref(); - let conn_pre = conn_pool.get().await; - let conn = &mut conn_pre.unwrap(); - - let sqlx_pool_ref = sqlx_pool.as_ref().as_ref(); - - let departure_time = match query.departure_time { - Some(departure_time) => departure_time, - None => catenary::duration_since_unix_epoch().as_secs(), - }; - - let departure_time_chrono = match query.departure_time { - Some(x) => chrono::Utc.timestamp_opt(x.try_into().unwrap(), 0).unwrap(), - None => chrono::Utc::now(), - }; - - let seek_back = chrono::TimeDelta::new(5400, 0).unwrap(); - - let seek_forward = chrono::TimeDelta::new(3600 * 24, 0).unwrap(); - - let stops: diesel::prelude::QueryResult> = - catenary::schema::gtfs::stops::dsl::stops - .filter(catenary::schema::gtfs::stops::dsl::chateau.eq(&query.chateau_id)) - .filter(catenary::schema::gtfs::stops::dsl::gtfs_id.eq(&query.stop_id)) - .select(catenary::models::Stop::as_select()) - .load::(conn) - .await; - - let directions_timer = Instant::now(); - - let directions_fetch_query = sql_query(format!( - " - SELECT * FROM gtfs.direction_pattern JOIN - gtfs.stops ON direction_pattern.chateau = stops.chateau - AND direction_pattern.stop_id = stops.gtfs_id - AND direction_pattern.attempt_id = stops.attempt_id - WHERE gtfs.stops.point = {} AND gtfs.stops.chateau = {} - AND allowed_spatial_query = TRUE; - ", - query.stop_id, query.chateau_id - )); - - println!( - "Finished getting direction-stops in {:?}", - directions_timer.elapsed() - ); - - let directions_fetch_sql: Result, diesel::result::Error> = - directions_fetch_query.get_results(conn).await; - - let directions_rows = directions_fetch_sql.unwrap(); - - let set_of_directions = directions_rows - .iter() - .map(|x| (x.direction_pattern_id.clone(), x.stop_sequence)) - .collect::>(); - - let formatted_ask = format!( - "({})", - set_of_directions - .into_iter() - .map(|x| format!("('{}',{})", x.0, x.1)) - .collect::>() - .join(",") - ); - - let seek_itins: Vec = - - diesel::sql_query( - format!( - "SELECT -itinerary_pattern.onestop_feed_id, -itinerary_pattern.attempt_id, -itinerary_pattern.itinerary_pattern_id, -itinerary_pattern.stop_sequence, -itinerary_pattern.arrival_time_since_start, -itinerary_pattern.departure_time_since_start, -itinerary_pattern.interpolated_time_since_start, -itinerary_pattern.stop_id, -itinerary_pattern.chateau, -itinerary_pattern.gtfs_stop_sequence, -itinerary_pattern_meta.direction_pattern_id, -itinerary_pattern_meta.trip_headsign, -itinerary_pattern_meta.trip_headsign_translations, -itinerary_pattern_meta.timezone, -itinerary_pattern_meta.route_id -FROM gtfs.itinerary_pattern JOIN - gtfs.itinerary_pattern_meta ON - itinerary_pattern_meta.itinerary_pattern_id = itinerary_pattern.itinerary_pattern_id -AND itinerary_pattern_meta.chateau = '{}' -AND itinerary_pattern.chateau = '{}' AND -itinerary_pattern.onestop_feed_id = itinerary_pattern_meta.onestop_feed_id -AND - (itinerary_pattern_meta.direction_pattern_id, itinerary_pattern.stop_sequence) IN {}",query.chateau_id, query.chateau_id, formatted_ask)).get_results(conn).await.unwrap(); - - let set_of_itin = seek_itins - .iter() - .map(|x| x.itinerary_pattern_id.clone()) - .collect::>(); - - println!("Looking up trips"); - let timer_trips = Instant::now(); - - let query_trips_compressed = catenary::schema::gtfs::trips_compressed::dsl::trips_compressed - .filter(catenary::schema::gtfs::trips_compressed::dsl::chateau.eq(&query.chateau_id)) - .filter( - catenary::schema::gtfs::trips_compressed::dsl::itinerary_pattern_id.eq_any(set_of_itin), - ) - .select(catenary::models::CompressedTrip::as_select()) - .load::(conn) - .await - .unwrap(); - - println!("Finished looking up trips in {:?}", timer_trips.elapsed()); - - let mut compressed_trips: Vec = vec![]; - - let mut services_to_lookup: BTreeSet = BTreeSet::new(); - - let mut routes_to_lookup: BTreeSet = BTreeSet::new(); - - for trip in query_trips_compressed { - compressed_trips.push(trip.clone()); - services_to_lookup.insert(trip.service_id.clone()); - routes_to_lookup.insert(trip.route_id.clone()); - } - - let calendar_timer = Instant::now(); - - let (services_calendar_lookup, services_calendar_dates_lookup, routes_query) = tokio::join!( - catenary::schema::gtfs::calendar::dsl::calendar - .filter(catenary::schema::gtfs::calendar::dsl::chateau.eq(&query.chateau_id)) - .filter( - catenary::schema::gtfs::calendar::dsl::service_id - .eq_any(services_to_lookup.clone()) - ) - .select(catenary::models::Calendar::as_select()) - .load::(conn), - catenary::schema::gtfs::calendar_dates::dsl::calendar_dates - .filter(catenary::schema::gtfs::calendar_dates::dsl::chateau.eq(&query.chateau_id)) - .filter( - catenary::schema::gtfs::calendar_dates::dsl::service_id - .eq_any(services_to_lookup.clone()), - ) - .select(catenary::models::CalendarDate::as_select()) - .load::(conn), - catenary::schema::gtfs::routes::dsl::routes - .filter(catenary::schema::gtfs::routes::dsl::chateau.eq(&query.chateau_id)) - .filter(catenary::schema::gtfs::routes::dsl::route_id.eq_any(routes_to_lookup)) - .select(catenary::models::Route::as_select()) - .load::(conn), - ); - - println!( - "Finished getting calendar, routes, and calendar dates, took {:?}", - calendar_timer.elapsed() - ); - - let calendar_structure = make_calendar_structure_from_pg_single_chateau( - services_calendar_lookup.unwrap(), - services_calendar_dates_lookup.unwrap(), - ); - - let mut route_table: HashMap = HashMap::new(); - - for route in routes_query.unwrap() { - route_table.insert(route.route_id.clone(), route); - } - - let mut trips_table: HashMap> = HashMap::new(); - - for trip in compressed_trips {} - - HttpResponse::Ok().json("Hello") -} - #[actix_web::get("/nearbydeparturesfromcoords")] pub async fn nearby_from_coords( req: HttpRequest, diff --git a/src/maple/gtfs_handlers/colour_correction.rs b/src/maple/gtfs_handlers/colour_correction.rs index 69dbc74..8b7d66d 100644 --- a/src/maple/gtfs_handlers/colour_correction.rs +++ b/src/maple/gtfs_handlers/colour_correction.rs @@ -78,7 +78,7 @@ pub fn fix_background_colour_rgb_feed_route( "510" => RGB::new(0, 112, 191), "520" => RGB::new(255, 143, 0), "530" => RGB::new(0, 171, 70), - "535" => RGB::new(175, 99, 49), + "535" => RGB::new(184, 115, 51), "888" | "891" | "892" | "894" => RGB::new(98, 54, 27), _ => RGB::new(220, 38, 38), }, diff --git a/transitland-atlas b/transitland-atlas index 4210979..e4d90d2 160000 --- a/transitland-atlas +++ b/transitland-atlas @@ -1 +1 @@ -Subproject commit 4210979e74478e828cb510bf70cf88b2f26d8d1e +Subproject commit e4d90d28c396cb8c20b730f6b90c52d3cced6265