Skip to content

Commit

Permalink
Improved ETL
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecardleitao committed Feb 9, 2024
1 parent 42e17e6 commit ccf8236
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 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(())
}
9 changes: 3 additions & 6 deletions examples/export_private_jets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,17 @@ async fn main() -> Result<(), Box<dyn Error>> {
It contains 3 columns:
* `icao_number`: The transponder identifier
* `tail_number`: The tail number of the aircraft
* `model`: The icao number of the aircraft type. It is only one of the ones
identified as private jet according to the methodology.
* `model`: The model of the aircraft. It is only one of the ones identified as private jet according to the methodology.
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 ccf8236

Please sign in to comment.