Support account IDs
This commit is contained in:
+7
-2
@@ -44,6 +44,10 @@ enum Commands {
|
||||
Csv {
|
||||
/// The path of the CSV file to ingest.
|
||||
csv_file: PathBuf,
|
||||
|
||||
/// The name of the account to ingest the CSV for.
|
||||
#[clap(long, short)]
|
||||
account: String,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -94,7 +98,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
serve_web(addr, connection).await?;
|
||||
}
|
||||
|
||||
Commands::Csv { csv_file } => {
|
||||
Commands::Csv { csv_file, account: account_name } => {
|
||||
let mut csv = csv::Reader::from_reader(File::open(csv_file)?);
|
||||
let data = csv.records();
|
||||
let data = data
|
||||
@@ -102,7 +106,8 @@ async fn main() -> anyhow::Result<()> {
|
||||
.map(from_csv_row)
|
||||
.collect::<Result<_, _>>()?;
|
||||
|
||||
db::insert(&connection, data).await?;
|
||||
let account_id = db::get_account_id(&connection, Some(account_name)).await?;
|
||||
db::insert(&connection, data, account_id).await?;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user