aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/store/sqlite.rs48
1 files changed, 46 insertions, 2 deletions
diff --git a/src/app/store/sqlite.rs b/src/app/store/sqlite.rs
index e124675..258a12f 100644
--- a/src/app/store/sqlite.rs
+++ b/src/app/store/sqlite.rs
@@ -202,9 +202,18 @@ impl SQLiteStore {
fn exec_migration_list(&mut self) -> Result<Vec<SQLiteMigration>, ContextError> {
let conn = self.get_connection()?;
+ tracing::event!(
+ tracing::Level::TRACE,
+ "Preparing statement to select from migration_control table."
+ );
+
let statement = conn.prepare(Self::MIGRATION_CONTROL_SELECT_QUERY);
if statement.is_err() {
+ tracing::event!(
+ tracing::Level::TRACE,
+ "Executing create table migration_control."
+ );
conn.execute(Self::MIGRATION_CONTROL_CREATE_QUERY)?;
Ok(vec![])
} else {
@@ -216,7 +225,11 @@ impl SQLiteStore {
}
/// Executes a migration against the database, and inserts a migration record into the migration_control table.
- fn run_and_insert_migration(&mut self, id: usize, migration: &db::Migration) -> Result<(), ContextError> {
+ fn run_and_insert_migration(
+ &mut self,
+ id: usize,
+ migration: &db::Migration,
+ ) -> Result<(), ContextError> {
let conn = self.get_connection()?;
let timestamp = Local::now().to_string();
tracing::event!(
@@ -229,6 +242,11 @@ impl SQLiteStore {
);
conn.execute(migration.script_contents.clone())?;
+ tracing::event!(
+ tracing::Level::TRACE,
+ migration_id = id,
+ "Preparing statement to insert into migration_control table."
+ );
let mut statement = conn.prepare(Self::MIGRATION_CONTROL_INSERT_QUERY)?;
statement.bind::<&[(_, sqlite::Value)]>(&[
(":migration_id", i64::try_from(id)?.into()),
@@ -276,7 +294,6 @@ impl SQLiteStore {
Ok(())
}
-
}
impl Default for SQLiteStore {
@@ -304,6 +321,10 @@ impl Store for SQLiteStore {
fn get_accounts(&self) -> Result<Vec<FiduciaryAccount>, ContextError> {
let conn = self.get_connection()?;
+ tracing::event!(
+ tracing::Level::TRACE,
+ "Preparing statement to select from fiduciary_account table."
+ );
let statement = conn.prepare(Self::FIDUCIARY_ACCOUNT_SELECT_QUERY)?;
statement
@@ -316,6 +337,11 @@ impl Store for SQLiteStore {
fn add_account(&mut self, account: &FiduciaryAccount) -> Result<(), ContextError> {
let conn = self.get_connection()?;
+ tracing::event!(
+ tracing::Level::TRACE,
+ fiduciary_account_id = account.fiduciary_account_id,
+ "Preparing statement to insert into fiduciary_account table."
+ );
let mut statement = conn.prepare(Self::FIDUCIARY_ACCOUNT_INSERT_QUERY)?;
statement.bind::<&[(_, sqlite::Value)]>(&[
@@ -350,6 +376,10 @@ impl Store for SQLiteStore {
fn get_symbols(&self) -> Result<Vec<EquitySymbol>, ContextError> {
let conn = self.get_connection()?;
+ tracing::event!(
+ tracing::Level::TRACE,
+ "Preparing statement to select from equity_symbol table."
+ );
let statement = conn.prepare(Self::EQUITY_SYMBOL_SELECT_QUERY)?;
statement.into_iter().map(EquitySymbol::try_from).collect()
@@ -359,6 +389,11 @@ impl Store for SQLiteStore {
fn add_symbol(&mut self, symbol: &EquitySymbol) -> Result<(), ContextError> {
let conn = self.get_connection()?;
+ tracing::event!(
+ tracing::Level::TRACE,
+ equity_symbol_id = symbol.equity_symbol_id,
+ "Preparing statement to insert into equity_symbol table."
+ );
let mut statement = conn.prepare(Self::EQUITY_SYMBOL_INSERT_QUERY)?;
statement.bind::<&[(_, sqlite::Value)]>(&[
@@ -390,6 +425,10 @@ impl Store for SQLiteStore {
fn get_events(&self) -> Result<Vec<EquityChangeEvent>, ContextError> {
let conn = self.get_connection()?;
+ tracing::event!(
+ tracing::Level::TRACE,
+ "Preparing statement to select from equity_change_event table."
+ );
let statement = conn.prepare(Self::EQUITY_CHANGE_EVENT_SELECT_QUERY)?;
statement
@@ -402,6 +441,11 @@ impl Store for SQLiteStore {
fn add_event(&mut self, event: &EquityChangeEvent) -> Result<(), ContextError> {
let conn = self.get_connection()?;
+ tracing::event!(
+ tracing::Level::TRACE,
+ equity_change_event_id = event.equity_change_event_id,
+ "Preparing statement to insert into equity_change_event table."
+ );
let mut statement = conn.prepare(Self::EQUITY_SYMBOL_INSERT_QUERY)?;
statement.bind::<&[(_, sqlite::Value)]>(&[