Skip to content

Commit

Permalink
Improved ETL
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecardleitao committed Feb 10, 2024
1 parent 7e51197 commit 253f2d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
26 changes: 14 additions & 12 deletions examples/etl_legs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,16 +213,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
.await?
.len();

write_json(
client.unwrap(),
Metadata {
icao_months_to_process: required,
icao_months_processed: processed + completed.len(),
},
"status",
)
.await?;

let client = client.unwrap();
let completed = existing(&client)
.await?
Expand All @@ -231,8 +221,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
.collect::<HashSet<_>>();

let tasks = completed
.into_iter()
.map(|(icao, date)| async move { read(&icao, date, client).await });
.iter()
.map(|(icao, date)| async move { read(icao, *date, client).await });

let legs = futures::stream::iter(tasks)
.buffered(20)
Expand All @@ -243,6 +233,18 @@ async fn main() -> Result<(), Box<dyn Error>> {

let key = format!("{DATABASE_ROOT}all.csv");
write_csv(legs, &key, client).await?;
log::info!("Written {key}");

write_json(
client,
Metadata {
icao_months_to_process: required,
icao_months_processed: processed + completed.len(),
},
"status",
)
.await?;
log::info!("status written");

Ok(())
}
6 changes: 2 additions & 4 deletions examples/export_private_jets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,10 @@ Both `icao_number` and `tail_number` are unique keys (independently).

if client.as_ref().map(|c| c.can_put()).unwrap_or(false) {
let client = client.unwrap();
client
.put("database/private_jets/2023/11/06/data.csv", data_csv)
.await?;
client.put("private_jets/all.csv", data_csv).await?;
client
.put(
"database/private_jets/2023/11/06/description.md",
"private_jets/description.md",
specification_md.as_bytes().to_vec(),
)
.await?;
Expand Down

0 comments on commit 253f2d3

Please sign in to comment.