Skip to content

Commit

Permalink
search for itin metas
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Nov 30, 2024
1 parent 6095b96 commit 2fe284b
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions src/birch/nearby_departures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,24 +421,44 @@ pub async fn nearby_from_coords(
.join(",")
);*/

println!("Search for matching itinerary ids");

let itin_meta_timer = Instant::now();

let itineraries_meta_search_list = futures::stream::iter(hashmap_of_directions_lookup.iter().map(
|(chateau, set_of_directions)|
{
catenary::schema::gtfs::itinerary_pattern_meta::dsl::itinerary_pattern_meta
.filter(catenary::schema::gtfs::itinerary_pattern_meta::dsl::chateau.eq(chateau.clone()))
.filter(
catenary::schema::gtfs::itinerary_pattern_meta::dsl::direction_pattern_id
.eq_any(set_of_directions.iter().map(|x| x.0.clone()).collect::<Vec<String>>()),
)
.select(catenary::models::ItineraryPatternMeta::as_select())
.load::<catenary::models::ItineraryPatternMeta>(conn)
}
)).buffer_unordered(10).collect::<Vec<diesel::QueryResult<Vec<ItineraryPatternMeta>>>>().await;

println!(
"Finished getting itinerary metas in {:?}",
itin_meta_timer.elapsed()
);

println!("Starting to search for itineraries");

let itineraries_timer = Instant::now();

let seek_for_itineraries_list = futures::stream::iter(hashmap_of_directions_lookup.into_iter().map(
|(chateau, set_of_directions)|
{
let formatted_ask = match chateau.as_str() {
"bus~dft~gov~uk" => String::from("()"),
_ => format!(
"({})",
set_of_directions
.into_iter()
.map(|x| format!("('{}',{})" , x.0, x.1))
.collect::<Vec<String>>()
.join(",")
)
};
let formatted_ask = format!(
"({})",
set_of_directions
.into_iter()
.map(|x| format!("('{}',{})" , x.0, x.1))
.collect::<Vec<String>>()
.join(",")
);

//EXTREMELY SLOW QUERY
diesel::sql_query(
Expand Down

0 comments on commit 2fe284b

Please sign in to comment.