diff --git a/Cargo.toml b/Cargo.toml index 9f7d62b..be62ae9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -33,7 +33,7 @@ tokio = { version = "1.47.1", features = ["macros", "rt-mu tower-http = { version = "0.6.6", features = ["fs"] } tower-sessions = { version = "0.14.0", features = ["signed"] } tower-sessions-sqlx-store = { version = "0.15.0", features = ["sqlite"] } -tracing = "0.1.41" +tracing = { version = "0.1.41", features = ["attributes"] } tracing-subscriber = { version = "0.3.20", features = ["env-filter"] } vcard = "0.4.13" diff --git a/migrations/demo.sql b/migrations/demo.sql index 48d40df..17bda4c 100644 --- a/migrations/demo.sql +++ b/migrations/demo.sql @@ -55,12 +55,12 @@ insert into journal_entries(id, date, value) values (5, '2024-02-18', 'With [[Bazel]] gone, dissolved [[ABC]] Corp. Start discussions for a potential ACE, Inc. with [[Alexi]] and [[Eleanor]].'); insert into mentions (entity_id, entity_type, input_text, byte_range_start, byte_range_end, url) values - (0, 'journal_entry', 'Bazel Bagend', 11, 27, '/contact/1'), - (1, 'journal_entry', 'Alexi', 12, 21, '/contact/0'), - (3, 'journal_entry', 'ABC', 24, 31, '/group/ABC'), - (4, 'journal_entry', 'Bazel', 22, 31, '/contact/1'), - (4, 'journal_entry', 'Eleanor Edgeworth', 37, 58, '/contact/3'), - (5, 'journal_entry', 'Eleanor', 108, 119, '/contact/3'), - (5, 'journal_entry', 'Alexi', 94, 103, '/contact/0'), - (5, 'journal_entry', 'Bazel', 5, 14, '/contact/1'), - (5, 'journal_entry', 'ABC', 31, 38, '/group/ABC'); + (0, 0, 'Bazel Bagend', 11, 27, '/contact/1'), + (1, 0, 'Alexi', 12, 21, '/contact/0'), + (3, 0, 'ABC', 24, 31, '/group/ABC'), + (4, 0, 'Bazel', 22, 31, '/contact/1'), + (4, 0, 'Eleanor Edgeworth', 37, 58, '/contact/3'), + (5, 0, 'Eleanor', 108, 119, '/contact/3'), + (5, 0, 'Alexi', 94, 103, '/contact/0'), + (5, 0, 'Bazel', 5, 14, '/contact/1'), + (5, 0, 'ABC', 31, 38, '/group/ABC'); diff --git a/src/db.rs b/src/db.rs index 359a3a3..4dd205e 100644 --- a/src/db.rs +++ b/src/db.rs @@ -23,12 +23,14 @@ impl Database { let pool = SqlitePoolOptions::new().connect_with(db_options).await?; + tracing::debug!("migrating..."); sqlx::migrate!("./migrations/each_user/").run(&pool).await?; if user.username == "demo" { sqlx::query_file!("./migrations/demo.sql") .execute(&pool) .await?; }; + tracing::debug!("...done."); Ok(Self { pool }) } diff --git a/src/web/home.rs b/src/web/home.rs index c3d37a3..a627b46 100644 --- a/src/web/home.rs +++ b/src/web/home.rs @@ -85,6 +85,7 @@ fn birthdays_section( }) } +#[tracing::instrument(level = "info")] pub async fn journal_section( pool: &SqlitePool, entries: &Vec, @@ -110,7 +111,7 @@ pub async fn journal_section( .entries { @for entry in entries { - (Into::::into(entry).format_pool(pool).await?) + (entry.to_html(pool).await?) } } } @@ -129,7 +130,7 @@ pub mod get { let pool = &state.db(&user).pool; let contacts: Vec = sqlx::query_as( - "select id, birthday, manually_freshened_at, ( + "select *, ( select string_agg(name,'\x1c' order by sort) from names where contact_id = c.id ) as names, (