diff options
| author | Kevin Hoerr <kjhoerr@submelon.dev> | 2026-05-04 17:07:43 -0400 |
|---|---|---|
| committer | Kevin Hoerr <kjhoerr@submelon.dev> | 2026-05-04 17:07:43 -0400 |
| commit | 397f8bd3fd1d36a9703b319c46db34b83950a9b2 (patch) | |
| tree | 516e6205c20894cf445d96aff2dac2eab0d19c94 /src/app/store | |
| parent | 2dea4de6c9213c9ab846d6b91367ed7ed7d1cfbd (diff) | |
| download | equity-tracker-397f8bd3fd1d36a9703b319c46db34b83950a9b2.tar.gz equity-tracker-397f8bd3fd1d36a9703b319c46db34b83950a9b2.tar.bz2 equity-tracker-397f8bd3fd1d36a9703b319c46db34b83950a9b2.zip | |
sqlite.rs: add method comment, format
Diffstat (limited to 'src/app/store')
| -rw-r--r-- | src/app/store/sqlite.rs | 89 |
1 files changed, 72 insertions, 17 deletions
diff --git a/src/app/store/sqlite.rs b/src/app/store/sqlite.rs index 67ec046..0fac2cd 100644 --- a/src/app/store/sqlite.rs +++ b/src/app/store/sqlite.rs @@ -199,6 +199,7 @@ impl SQLiteStore { } } + /// Attempts to get the migration list from the database; if that fails, creates the migration table and returns an empty vec fn exec_migration_list(&mut self) -> Result<Vec<SQLiteMigration>, ContextError> { let conn = self.get_connection()?; @@ -303,11 +304,29 @@ impl SQLiteStore { let mut statement = conn.prepare(Self::FIDUCIARY_ACCOUNT_INSERT_QUERY)?; statement.bind::<&[(_, sqlite::Value)]>(&[ - (":fiduciary_account_id", i64::from(account.fiduciary_account_id).into()), - (":fiduciary_account_name", account.fiduciary_account_name.clone().into()), - (":fiduciary_account_number", i64::try_from(account.fiduciary_account_number)?.into()), - (":fiduciary_account_description", account.fiduciary_account_description.clone().into()), - (":fiduciary_account_created_timestamp", account.fiduciary_account_created_timestamp.to_string().into()), + ( + ":fiduciary_account_id", + i64::from(account.fiduciary_account_id).into(), + ), + ( + ":fiduciary_account_name", + account.fiduciary_account_name.clone().into(), + ), + ( + ":fiduciary_account_number", + i64::try_from(account.fiduciary_account_number)?.into(), + ), + ( + ":fiduciary_account_description", + account.fiduciary_account_description.clone().into(), + ), + ( + ":fiduciary_account_created_timestamp", + account + .fiduciary_account_created_timestamp + .to_string() + .into(), + ), ])?; Ok(()) } @@ -340,11 +359,26 @@ impl SQLiteStore { let mut statement = conn.prepare(Self::EQUITY_SYMBOL_INSERT_QUERY)?; statement.bind::<&[(_, sqlite::Value)]>(&[ - (":equity_symbol_id", i64::try_from(symbol.equity_symbol_id)?.into()), - (":equity_symbol_name", symbol.equity_symbol_name.clone().into()), - (":equity_symbol_type", symbol.equity_symbol_type.to_string().into()), - (":equity_symbol_managing_company", symbol.equity_symbol_managing_company.clone().into()), - (":equity_symbol_created_timestamp", symbol.equity_symbol_created_timestamp.to_string().into()), + ( + ":equity_symbol_id", + i64::try_from(symbol.equity_symbol_id)?.into(), + ), + ( + ":equity_symbol_name", + symbol.equity_symbol_name.clone().into(), + ), + ( + ":equity_symbol_type", + symbol.equity_symbol_type.to_string().into(), + ), + ( + ":equity_symbol_managing_company", + symbol.equity_symbol_managing_company.clone().into(), + ), + ( + ":equity_symbol_created_timestamp", + symbol.equity_symbol_created_timestamp.to_string().into(), + ), ])?; Ok(()) } @@ -381,13 +415,34 @@ impl SQLiteStore { let mut statement = conn.prepare(Self::EQUITY_SYMBOL_INSERT_QUERY)?; statement.bind::<&[(_, sqlite::Value)]>(&[ - (":equity_change_event_id", i64::try_from(event.equity_change_event_id)?.into()), - (":fiduciary_account_id", i64::from(event.fiduciary_account_id).into()), - (":equity_symbol_id", i64::try_from(event.equity_symbol_id)?.into()), - (":equity_change_quantity", event.equity_change_quantity.to_f64().into()), - (":equity_change_cost_basis", event.equity_change_cost_basis.to_f64().into()), - (":equity_change_type", event.equity_change_type.to_string().into()), - (":equity_change_timestamp", event.equity_change_timestamp.to_string().into()), + ( + ":equity_change_event_id", + i64::try_from(event.equity_change_event_id)?.into(), + ), + ( + ":fiduciary_account_id", + i64::from(event.fiduciary_account_id).into(), + ), + ( + ":equity_symbol_id", + i64::try_from(event.equity_symbol_id)?.into(), + ), + ( + ":equity_change_quantity", + event.equity_change_quantity.to_f64().into(), + ), + ( + ":equity_change_cost_basis", + event.equity_change_cost_basis.to_f64().into(), + ), + ( + ":equity_change_type", + event.equity_change_type.to_string().into(), + ), + ( + ":equity_change_timestamp", + event.equity_change_timestamp.to_string().into(), + ), ])?; Ok(()) } |
