Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kylerchin committed Mar 27, 2024
1 parent 020e372 commit a157e68
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 33 deletions.
52 changes: 26 additions & 26 deletions src/maple/gtfs_process.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use diesel::prelude::*;
use diesel_async::RunQueryDsl;
use dotenvy::dotenv;
use postgis::ewkb;
use rgb::RGB;
Expand All @@ -7,17 +8,16 @@ 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;
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
Expand All @@ -30,33 +30,33 @@ pub async fn gtfs_process_feed(
attempt_id: &str,
this_download_data: &DownloadedFeedsInformation,
) -> Result<(), Box<dyn Error>> {
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);
Expand Down
15 changes: 8 additions & 7 deletions src/maple/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,16 @@ async fn run_ingest() -> Result<(), Box<dyn Error>> {
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 {
Expand Down Expand Up @@ -361,8 +363,7 @@ async fn run_ingest() -> Result<(), Box<dyn Error>> {
}
}
});
}

}
}
} else {
eprintln!("Not enough data in transitland!");
Expand Down

0 comments on commit a157e68

Please sign in to comment.