Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(email_service): update ThreadHistoryInfo in preparation for search changes (#350)

Will Hutchinson664d6a7eb8a6
diff --git a/rust/cloud-storage/email_db_client/.sqlx/query-120abddd2c7bae7372351b33e7809f5141da3adcd699fcbd5b38a2aa7b81062a.json b/rust/cloud-storage/email_db_client/.sqlx/query-4fef13bb7ed412b7797054c7886b5f39a2c02943023e41ebb7f24d67804b5f86.json
similarity index 55%
rename from rust/cloud-storage/email_db_client/.sqlx/query-120abddd2c7bae7372351b33e7809f5141da3adcd699fcbd5b38a2aa7b81062a.json
rename to rust/cloud-storage/email_db_client/.sqlx/query-4fef13bb7ed412b7797054c7886b5f39a2c02943023e41ebb7f24d67804b5f86.json
index f5c7f9548f..a197727611 100644
--- a/rust/cloud-storage/email_db_client/.sqlx/query-120abddd2c7bae7372351b33e7809f5141da3adcd699fcbd5b38a2aa7b81062a.json
+++ b/rust/cloud-storage/email_db_client/.sqlx/query-4fef13bb7ed412b7797054c7886b5f39a2c02943023e41ebb7f24d67804b5f86.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n m.thread_id,\n MIN(m.created_at) as \"earliest_created_at!\",\n MAX(m.created_at) as \"latest_updated_at!\",\n uh.updated_at as \"viewed_at?\",\n m.snippet\n FROM email_messages m\n LEFT JOIN email_user_history uh ON uh.thread_id = m.thread_id AND uh.link_id = $1\n WHERE m.thread_id = ANY($2)\n AND m.link_id = $1\n GROUP BY m.thread_id, uh.updated_at, m.snippet\n ",
+ "query": "\n SELECT\n m.thread_id,\n MIN(m.created_at) as \"earliest_created_at!\",\n MAX(m.created_at) as \"latest_updated_at!\",\n uh.updated_at as \"viewed_at?\",\n m.snippet,\n m.subject as \"subject?\",\n l.macro_id\n FROM email_messages m\n LEFT JOIN email_user_history uh ON uh.thread_id = m.thread_id AND uh.link_id = $1\n LEFT JOIN email_links l ON l.id = m.link_id\n WHERE m.thread_id = ANY($2)\n AND m.link_id = $1\n GROUP BY m.thread_id, uh.updated_at, m.snippet, m.subject, l.macro_id\n ",
"describe": {
"columns": [
{
@@ -27,6 +27,16 @@
"ordinal": 4,
"name": "snippet",
"type_info": "Text"
+ },
+ {
+ "ordinal": 5,
+ "name": "subject?",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 6,
+ "name": "macro_id",
+ "type_info": "Text"
}
],
"parameters": {
@@ -40,8 +50,10 @@
null,
null,
false,
- true
+ true,
+ true,
+ false
]
},
- "hash": "120abddd2c7bae7372351b33e7809f5141da3adcd699fcbd5b38a2aa7b81062a"
+ "hash": "4fef13bb7ed412b7797054c7886b5f39a2c02943023e41ebb7f24d67804b5f86"
}
diff --git a/rust/cloud-storage/email_db_client/src/user_history/mod.rs b/rust/cloud-storage/email_db_client/src/user_history/mod.rs
index 9aae68ade3..2ef3f59a2d 100644
--- a/rust/cloud-storage/email_db_client/src/user_history/mod.rs
+++ b/rust/cloud-storage/email_db_client/src/user_history/mod.rs
@@ -48,12 +48,15 @@ pub async fn get_thread_summary_info(
MIN(m.created_at) as "earliest_created_at!",
MAX(m.created_at) as "latest_updated_at!",
uh.updated_at as "viewed_at?",
- m.snippet
+ m.snippet,
+ m.subject as "subject?",
+ l.macro_id
FROM email_messages m
LEFT JOIN email_user_history uh ON uh.thread_id = m.thread_id AND uh.link_id = $1
+ LEFT JOIN email_links l ON l.id = m.link_id
WHERE m.thread_id = ANY($2)
AND m.link_id = $1
- GROUP BY m.thread_id, uh.updated_at, m.snippet
+ GROUP BY m.thread_id, uh.updated_at, m.snippet, m.subject, l.macro_id
"#,
link_id,
thread_ids
@@ -67,6 +70,8 @@ pub async fn get_thread_summary_info(
for row in rows {
let summary_info = ThreadHistoryInfo {
item_id: row.thread_id,
+ user_id: row.macro_id,
+ subject: row.subject,
snippet: row.snippet,
created_at: row.earliest_created_at,
updated_at: row.latest_updated_at,
diff --git a/rust/cloud-storage/models_email/src/email/service/message.rs b/rust/cloud-storage/models_email/src/email/service/message.rs
index 0605822796..8ac0c532de 100644
--- a/rust/cloud-storage/models_email/src/email/service/message.rs
+++ b/rust/cloud-storage/models_email/src/email/service/message.rs
@@ -308,6 +308,8 @@ pub struct ThreadHistoryInfo {
pub updated_at: DateTime<Utc>,
pub viewed_at: Option<DateTime<Utc>>,
pub snippet: Option<String>,
+ pub user_id: String,
+ pub subject: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
diff --git a/rust/cloud-storage/search_service/src/api/search/email/test.rs b/rust/cloud-storage/search_service/src/api/search/email/test.rs
index 03e68fb1c0..910e8db819 100644
--- a/rust/cloud-storage/search_service/src/api/search/email/test.rs
+++ b/rust/cloud-storage/search_service/src/api/search/email/test.rs
@@ -11,6 +11,8 @@ fn create_email_history(thread_id: &str) -> models_email::service::message::Thre
updated_at: now,
viewed_at: None,
snippet: None,
+ user_id: "user1".to_string(),
+ subject: Some("subject".to_string()),
}
}