From a157e6892aaf4430c326d631daf09f6aaa8db2e1 Mon Sep 17 00:00:00 2001 From: Kyler Chin <7539174+kylerchin@users.noreply.github.com> Date: Wed, 27 Mar 2024 01:34:46 -0700 Subject: [PATCH] cargo fmt --- src/maple/gtfs_process.rs | 52 +++++++++++++++++++-------------------- src/maple/main.rs | 15 +++++------ 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/maple/gtfs_process.rs b/src/maple/gtfs_process.rs index 1f1b315c..4f067c0a 100644 --- a/src/maple/gtfs_process.rs +++ b/src/maple/gtfs_process.rs @@ -1,4 +1,5 @@ use diesel::prelude::*; +use diesel_async::RunQueryDsl; use dotenvy::dotenv; use postgis::ewkb; use rgb::RGB; @@ -7,7 +8,6 @@ use std::collections::HashSet; use std::env; use std::error::Error; use std::sync::Arc; -use diesel_async::RunQueryDsl; use crate::gtfs_handlers::colour_correction; use crate::gtfs_handlers::enum_to_int::route_type_to_int; @@ -15,9 +15,9 @@ use crate::gtfs_handlers::rename_route_labels::*; use crate::gtfs_handlers::shape_colour_calculator::shape_to_colour; use crate::gtfs_handlers::stops_associated_items::*; use crate::gtfs_ingestion_sequence::shapes_into_postgres::shapes_into_postgres; +use crate::DownloadedFeedsInformation; use catenary::postgres_tools::CatenaryPostgresConnection; use catenary::postgres_tools::CatenaryPostgresPool; -use crate::DownloadedFeedsInformation; // Initial version 3 of ingest written by Kyler Chin // Removal of the attribution is not allowed, as covered under the AGPL license @@ -30,33 +30,33 @@ pub async fn gtfs_process_feed( attempt_id: &str, this_download_data: &DownloadedFeedsInformation, ) -> Result<(), Box> { - let conn_pool = arc_conn_pool.as_ref(); - let conn_pre = conn_pool.get().await; - let conn = &mut conn_pre?; + let conn_pool = arc_conn_pool.as_ref(); + let conn_pre = conn_pool.get().await; + let conn = &mut conn_pre?; - //CREATE entry in gtfs.ingested_static - use catenary::schema::gtfs::ingested_static::dsl::ingested_static; + //CREATE entry in gtfs.ingested_static + use catenary::schema::gtfs::ingested_static::dsl::ingested_static; - let ingestion_static_data = catenary::models::IngestedStatic { - onestop_feed_id: feed_id.to_string(), - attempt_id: attempt_id.to_string(), - file_hash: this_download_data.hash.unwrap().clone().to_string(), - ingest_start_unix_time_ms: chrono::Utc::now().timestamp_millis(), - ingestion_version: crate::gtfs_handlers::MAPLE_INGESTION_VERSION, - ingesting_in_progress: true, - ingestion_successfully_finished: false, - ingestion_errored: false, - production: false, - deleted: false, - feed_expiration_date: None, - feed_start_date: None, - languages_avaliable: Vec::new(), - }; + let ingestion_static_data = catenary::models::IngestedStatic { + onestop_feed_id: feed_id.to_string(), + attempt_id: attempt_id.to_string(), + file_hash: this_download_data.hash.unwrap().clone().to_string(), + ingest_start_unix_time_ms: chrono::Utc::now().timestamp_millis(), + ingestion_version: crate::gtfs_handlers::MAPLE_INGESTION_VERSION, + ingesting_in_progress: true, + ingestion_successfully_finished: false, + ingestion_errored: false, + production: false, + deleted: false, + feed_expiration_date: None, + feed_start_date: None, + languages_avaliable: Vec::new(), + }; - diesel::insert_into(ingested_static) - .values(&ingestion_static_data) - .execute(conn) - .await?; + diesel::insert_into(ingested_static) + .values(&ingestion_static_data) + .execute(conn) + .await?; //read the GTFS zip file let path = format!("gtfs_uncompressed/{}", feed_id); diff --git a/src/maple/main.rs b/src/maple/main.rs index f62adee0..cbb71d32 100644 --- a/src/maple/main.rs +++ b/src/maple/main.rs @@ -301,14 +301,16 @@ async fn run_ingest() -> Result<(), Box> { async move { for (feed_id, _) in unzip_feeds .iter() - .filter(|unzipped_feed| unzipped_feed.1 == true) {} - + .filter(|unzipped_feed| unzipped_feed.1 == true) + {} } }); - for (feed_id, _) in unzip_feeds.iter().filter( - |unzipped_feed| unzipped_feed.1 == true) { - rt.spawn({ + for (feed_id, _) in unzip_feeds + .iter() + .filter(|unzipped_feed| unzipped_feed.1 == true) + { + rt.spawn({ let arc_conn_pool = Arc::clone(&arc_conn_pool); let download_feed_info_hashmap = Arc::clone(&download_feed_info_hashmap); async move { @@ -361,8 +363,7 @@ async fn run_ingest() -> Result<(), Box> { } } }); - } - + } } } else { eprintln!("Not enough data in transitland!");