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(comms_service): add more info to ChannelHistoryInfo for search (#349)

Will Hutchinsonf128a31dc2fb
diff --git a/rust/cloud-storage/comms_db_client/.sqlx/query-66ff9cb43b308c75526aa28728a687978759e3b12e70cbabefde41139b6641b9.json b/rust/cloud-storage/comms_db_client/.sqlx/query-6038d459d2d8e60479180f5b8a756380bda195f4769b6420e601ed147a9439f9.json
similarity index 51%
rename from rust/cloud-storage/comms_db_client/.sqlx/query-66ff9cb43b308c75526aa28728a687978759e3b12e70cbabefde41139b6641b9.json
rename to rust/cloud-storage/comms_db_client/.sqlx/query-6038d459d2d8e60479180f5b8a756380bda195f4769b6420e601ed147a9439f9.json
index c7e71e6a26..362ab4c5bc 100644
--- a/rust/cloud-storage/comms_db_client/.sqlx/query-66ff9cb43b308c75526aa28728a687978759e3b12e70cbabefde41139b6641b9.json
+++ b/rust/cloud-storage/comms_db_client/.sqlx/query-6038d459d2d8e60479180f5b8a756380bda195f4769b6420e601ed147a9439f9.json
@@ -1,6 +1,6 @@
{
"db_name": "PostgreSQL",
- "query": "\n SELECT\n c.\"id\" as \"item_id!\",\n c.created_at as \"created_at!\",\n c.updated_at as \"updated_at!\",\n uh.viewed_at as \"viewed_at?\",\n uh.interacted_at as \"interacted_at?\"\n FROM\n comms_channels c\n LEFT JOIN\n comms_activity uh ON uh.channel_id = c.id\n AND uh.user_id = $1\n WHERE\n c.id = ANY($2)\n ORDER BY\n c.updated_at DESC\n ",
+ "query": "\n SELECT\n c.\"id\" as \"item_id!\",\n c.created_at as \"created_at!\",\n c.updated_at as \"updated_at!\",\n uh.viewed_at as \"viewed_at?\",\n uh.interacted_at as \"interacted_at?\",\n c.owner_id as \"user_id\",\n c.channel_type AS \"channel_type: ChannelType\"\n FROM\n comms_channels c\n LEFT JOIN\n comms_activity uh ON uh.channel_id = c.id\n AND uh.user_id = $1\n WHERE\n c.id = ANY($2)\n ORDER BY\n c.updated_at DESC\n ",
"describe": {
"columns": [
{
@@ -27,6 +27,28 @@
"ordinal": 4,
"name": "interacted_at?",
"type_info": "Timestamp"
+ },
+ {
+ "ordinal": 5,
+ "name": "user_id",
+ "type_info": "Text"
+ },
+ {
+ "ordinal": 6,
+ "name": "channel_type: ChannelType",
+ "type_info": {
+ "Custom": {
+ "name": "comms_channel_type",
+ "kind": {
+ "Enum": [
+ "public",
+ "organization",
+ "private",
+ "direct_message"
+ ]
+ }
+ }
+ }
}
],
"parameters": {
@@ -40,8 +62,10 @@
false,
false,
true,
- true
+ true,
+ false,
+ false
]
},
- "hash": "66ff9cb43b308c75526aa28728a687978759e3b12e70cbabefde41139b6641b9"
+ "hash": "6038d459d2d8e60479180f5b8a756380bda195f4769b6420e601ed147a9439f9"
}
diff --git a/rust/cloud-storage/comms_db_client/src/activity/get_activity.rs b/rust/cloud-storage/comms_db_client/src/activity/get_activity.rs
index 98634befa3..08ed6f815f 100644
--- a/rust/cloud-storage/comms_db_client/src/activity/get_activity.rs
+++ b/rust/cloud-storage/comms_db_client/src/activity/get_activity.rs
@@ -1,7 +1,7 @@
use crate::model::Activity;
use anyhow::{Context, Result};
use chrono::{DateTime, Utc};
-use model::comms::{ChannelHistoryInfo, UserActivityForChannel};
+use model::comms::{ChannelHistoryInfo, ChannelType, UserActivityForChannel};
use sqlx::{Pool, Postgres};
use std::collections::HashMap;
use uuid::Uuid;
@@ -108,7 +108,9 @@ pub async fn get_channel_history_info(
c.created_at as "created_at!",
c.updated_at as "updated_at!",
uh.viewed_at as "viewed_at?",
- uh.interacted_at as "interacted_at?"
+ uh.interacted_at as "interacted_at?",
+ c.owner_id as "user_id",
+ c.channel_type AS "channel_type: ChannelType"
FROM
comms_channels c
LEFT JOIN
@@ -134,6 +136,8 @@ pub async fn get_channel_history_info(
updated_at: row.updated_at,
viewed_at: row.viewed_at.map(|dt| dt.and_utc()),
interacted_at: row.interacted_at.map(|dt| dt.and_utc()),
+ user_id: row.user_id,
+ channel_type: row.channel_type.to_string(),
};
(row.item_id, info)
})
diff --git a/rust/cloud-storage/model/src/comms/mod.rs b/rust/cloud-storage/model/src/comms/mod.rs
index 89cbcbd66c..8d193c7dd7 100644
--- a/rust/cloud-storage/model/src/comms/mod.rs
+++ b/rust/cloud-storage/model/src/comms/mod.rs
@@ -120,6 +120,8 @@ pub struct ChannelHistoryInfo {
pub updated_at: DateTime<Utc>,
pub viewed_at: Option<DateTime<Utc>>,
pub interacted_at: Option<DateTime<Utc>>,
+ pub user_id: String,
+ pub channel_type: String,
}
#[derive(Debug, Serialize, Deserialize)]
diff --git a/rust/cloud-storage/search_service/src/api/search/channel/test.rs b/rust/cloud-storage/search_service/src/api/search/channel/test.rs
index dbcde20042..8a432c78e4 100644
--- a/rust/cloud-storage/search_service/src/api/search/channel/test.rs
+++ b/rust/cloud-storage/search_service/src/api/search/channel/test.rs
@@ -210,6 +210,8 @@ fn create_channel_history(channel_id: &str) -> ChannelHistoryInfo {
updated_at: now,
viewed_at: None,
interacted_at: None,
+ user_id: "user_1".to_string(),
+ channel_type: "public".to_string(),
}
}
@@ -226,6 +228,8 @@ fn test_channel_history_timestamps() {
updated_at: now,
viewed_at: Some(now),
interacted_at: Some(now),
+ user_id: "user_1".to_string(),
+ channel_type: "public".to_string(),
};
channel_histories.insert(channel_uuid, history);
@@ -273,6 +277,8 @@ fn test_channel_history_missing_entry() {
updated_at: now,
viewed_at: None,
interacted_at: None,
+ user_id: "user_1".to_string(),
+ channel_type: "public".to_string(),
};
channel_histories.insert(different_channel_uuid, history);
@@ -306,6 +312,8 @@ fn test_channel_history_null_viewed_at() {
updated_at: now,
viewed_at: None, // This user has never viewed this channel
interacted_at: None, // This user has never interacted with this channel
+ user_id: "user_1".to_string(),
+ channel_type: "public".to_string(),
};
channel_histories.insert(channel_uuid, history);