Skip to content

Commit

Permalink
start timing the pg queries in aspen
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Nov 25, 2024
1 parent ff7bc2b commit 3caffb4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 29 deletions.
8 changes: 4 additions & 4 deletions src/aspen/import_alpenrose.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ use ahash::{AHashMap, AHashSet};
use catenary::aspen_dataset::*;
use catenary::postgres_tools::CatenaryPostgresPool;
use compact_str::CompactString;
use diesel::ExpressionMethods;
use diesel::QueryDsl;
use diesel::SelectableHelper;
use diesel::prelude::*;
use diesel_async::RunQueryDsl;
use gtfs_realtime::FeedMessage;
use scc::HashMap as SccHashMap;
Expand Down Expand Up @@ -712,6 +710,8 @@ pub async fn new_rt_data(
}
}
}

println!("Finished processing {} chateau took {:?} for route lookup, {:?} for trips, {:?} for itins", chateau_id,routes_query_elapsed, trip_duration, itin_lookup_duration);
}

//Insert data back into process-wide authoritative_data_store
Expand Down Expand Up @@ -750,7 +750,7 @@ pub async fn new_rt_data(
}
}

println!("Updated Chateau {}", chateau_id,);
println!("Updated Chateau {}", chateau_id);

Ok(true)
}
Expand Down
18 changes: 7 additions & 11 deletions src/birch/nearby_departures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,9 @@ use catenary::EtcdConnectionIps;
use chrono::TimeZone;
use compact_str::CompactString;
use diesel::dsl::sql;
use diesel::dsl::sql_query;
use diesel::query_dsl::methods::FilterDsl;
use diesel::query_dsl::methods::SelectDsl;
use diesel::prelude::*;
use diesel::sql_query;
use diesel::sql_types::Bool;
use diesel::ExpressionMethods;
use diesel::SelectableHelper;
use diesel_async::RunQueryDsl;
use futures::stream::futures_unordered;
use futures::stream::FuturesUnordered;
Expand Down Expand Up @@ -266,12 +263,11 @@ pub async fn nearby_from_coords(
let where_query_for_stops = format!("ST_DWithin(gtfs.stops.point, 'SRID=4326;POINT({} {})', {}) AND allowed_spatial_query = TRUE",
query.lon, query.lat, spatial_resolution_in_degs);

let stops: diesel::prelude::QueryResult<Vec<catenary::models::Stop>> =
catenary::schema::gtfs::stops::dsl::stops
.filter(sql::<Bool>(&where_query_for_stops))
.select(catenary::models::Stop::as_select())
.load::<catenary::models::Stop>(conn)
.await;
let stops: QueryResult<Vec<catenary::models::Stop>> = catenary::schema::gtfs::stops::dsl::stops
.filter(sql::<Bool>(&where_query_for_stops))
.select(catenary::models::Stop::as_select())
.load::<catenary::models::Stop>(conn)
.await;

let end_stops_duration = start_stops_query.elapsed();

Expand Down
26 changes: 12 additions & 14 deletions src/maple/gtfs_process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,21 @@ pub async fn gtfs_process_feed(
println!("Filtered TTC Subway");
gtfs.print_stats();
gtfs
},
}
"f-uc~irvine~anteater~express" => {
let mut gtfs = gtfs;

gtfs.feed_info = vec![
gtfs_structures::FeedInfo {
name: "TransLoc, Inc.".to_string(),
url: "https://transloc.com".to_string(),
lang: "en".to_string(),
start_date: Some(chrono::NaiveDate::from_ymd_opt(2024, 07, 10).unwrap()),
end_date: Some(chrono::NaiveDate::from_ymd_opt(2099, 12, 31).unwrap()),
version: None,
default_lang: Some("en".to_string()),
contact_email: None,
contact_url: None,
}
];
gtfs.feed_info = vec![gtfs_structures::FeedInfo {
name: "TransLoc, Inc.".to_string(),
url: "https://transloc.com".to_string(),
lang: "en".to_string(),
start_date: Some(chrono::NaiveDate::from_ymd_opt(2024, 07, 10).unwrap()),
end_date: Some(chrono::NaiveDate::from_ymd_opt(2099, 12, 31).unwrap()),
version: None,
default_lang: Some("en".to_string()),
contact_email: None,
contact_url: None,
}];

gtfs
}
Expand Down

0 comments on commit 3caffb4

Please sign in to comment.