Skip to content

Commit

Permalink
Fixed bins
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgecardleitao committed Mar 21, 2024
1 parent fed38c0 commit ca8c27a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/aircraft.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub async fn etl_aircrafts(client: Option<&fs_s3::ContainerClient>) -> Result<()

pub async fn read(
date: Date,
client: Option<&fs_s3::ContainerClient>,
client: Option<&dyn BlobStorageProvider>,
) -> Result<Aircrafts, String> {
let path = file_path(date);
let data = match client {
Expand Down
3 changes: 2 additions & 1 deletion src/bin/period.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,12 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
(Backend::Remote, _, _) => Some(flights::fs_s3::anonymous_client().await),
};
let client = client.as_ref().map(|x| x as &dyn BlobStorageProvider);

// load datasets to memory
let owners = load_owners()?;
let aircraft_owners = load_aircraft_owners()?;
let aircrafts = load_aircrafts(client.as_ref()).await?;
let aircrafts = aircraft::read(date!(2023 - 11 - 06), client).await?;

let from = cli.from;
let to = cli.to.unwrap_or(time::OffsetDateTime::now_utc().date());
Expand Down
9 changes: 6 additions & 3 deletions src/bin/single_day.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ use std::error::Error;

use clap::Parser;
use simple_logger::SimpleLogger;
use time::macros::date;
use tinytemplate::TinyTemplate;

use crate::aircraft::Aircrafts;
use flights::*;

static TEMPLATE: &str = include_str!(concat!(
Expand Down Expand Up @@ -82,7 +84,7 @@ async fn flight_date(
owners: &Owners,
aircraft_owners: &AircraftOwners,
aircrafts: &Aircrafts,
client: Option<&fs_s3::ContainerClient>,
client: Option<&dyn BlobStorageProvider>,
) -> Result<Vec<Event>, Box<dyn Error>> {
let models = load_private_jet_models()?;
let airports = airports_cached().await?;
Expand Down Expand Up @@ -190,10 +192,11 @@ async fn main() -> Result<(), Box<dyn Error>> {
}
(Backend::Remote, _, _) => Some(flights::fs_s3::anonymous_client().await),
};
let client = client.as_ref().map(|x| x as &dyn BlobStorageProvider);

let owners = load_owners()?;
let aircraft_owners = load_aircraft_owners()?;
let aircrafts = load_aircrafts(client.as_ref()).await?;
let aircrafts = aircraft::read(date!(2023 - 11 - 06), client).await?;

let dane_emissions_kg = Fact {
claim: 5100,
Expand All @@ -207,7 +210,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
&owners,
&aircraft_owners,
&aircrafts,
client.as_ref(),
client,
)
.await?;

Expand Down

0 comments on commit ca8c27a

Please sign in to comment.