-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move status to in progress table, create calendar feedinfo models
- Loading branch information
Showing
9 changed files
with
585 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
use catenary::postgres_tools::CatenaryPostgresPool; | ||
use std::error::Error; | ||
use diesel::query_dsl::methods::FilterDsl; | ||
use diesel::ExpressionMethods; | ||
use std::sync::Arc; | ||
use diesel::BoolExpressionMethods; | ||
use diesel_async::RunQueryDsl; | ||
|
||
pub async fn delete_attempt_objects(feed_id: &str, attempt_id: &str, pool: Arc<CatenaryPostgresPool>) -> Result<(), Box<dyn Error + std::marker::Send + Sync>> { | ||
use catenary::schema::gtfs::trips::dsl::trips as trips_table; | ||
use catenary::schema::gtfs::trips; | ||
|
||
let conn_pool = pool.as_ref(); | ||
let conn_pre = conn_pool.get().await; | ||
let conn = &mut conn_pre?; | ||
|
||
let _ = diesel::delete(trips_table.filter(trips::dsl::onestop_feed_id.eq(&feed_id).and(trips::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
use catenary::schema::gtfs::stoptimes::dsl::stoptimes as stop_times_table; | ||
use catenary::schema::gtfs::stoptimes; | ||
|
||
let _ = diesel::delete(stop_times_table.filter(stoptimes::dsl::onestop_feed_id.eq(&feed_id).and(stoptimes::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
//cleanup trip freq | ||
|
||
use catenary::schema::gtfs::trip_frequencies::dsl::trip_frequencies as frequencies_table; | ||
use catenary::schema::gtfs::trip_frequencies; | ||
let _ = diesel::delete(frequencies_table.filter(trip_frequencies::dsl::onestop_feed_id.eq(&feed_id).and(trip_frequencies::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
use catenary::schema::gtfs::agencies::dsl::agencies as agencies_table; | ||
use catenary::schema::gtfs::agencies; | ||
|
||
let _ = diesel::delete(agencies_table.filter(agencies::dsl::static_onestop_id.eq(&feed_id).and(agencies::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
use catenary::schema::gtfs::calendar_dates::dsl::calendar_dates as calendar_dates_table; | ||
use catenary::schema::gtfs::calendar_dates; | ||
|
||
let _ = diesel::delete(calendar_dates_table.filter(calendar_dates::dsl::onestop_feed_id.eq(&feed_id).and(calendar_dates::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
use catenary::schema::gtfs::calendar::dsl::calendar as calendar_table; | ||
use catenary::schema::gtfs::calendar; | ||
|
||
let _ = diesel::delete(calendar_table.filter(calendar::dsl::onestop_feed_id.eq(&feed_id).and(calendar::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
use catenary::schema::gtfs::routes::dsl::routes as routes_table; | ||
use catenary::schema::gtfs::routes; | ||
|
||
let _ = diesel::delete(routes_table.filter(routes::dsl::onestop_feed_id.eq(&feed_id).and(routes::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
use catenary::schema::gtfs::shapes::dsl::shapes as shapes_table; | ||
use catenary::schema::gtfs::shapes; | ||
|
||
let _ = diesel::delete(shapes_table.filter(shapes::dsl::onestop_feed_id.eq(&feed_id).and(shapes::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
use catenary::schema::gtfs::stops::dsl::stops as stops_table; | ||
use catenary::schema::gtfs::stops; | ||
|
||
let _ = diesel::delete(stops_table.filter(stops::dsl::onestop_feed_id.eq(&feed_id).and(stops::dsl::attempt_id.eq(&attempt_id)))) | ||
.execute(conn) | ||
.await; | ||
|
||
Ok(()) | ||
} |
Oops, something went wrong.