From 3f5ed6e4e46bd1d776a46542f07211ce2560fb12 Mon Sep 17 00:00:00 2001 From: ooodc <549496103@qq.com> Date: Tue, 5 May 2026 19:53:55 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=A7=BB=E9=99=A4=E4=B8=8D=E5=BF=85?= =?UTF-8?q?=E8=A6=81=E7=9A=84=20list=5Fmemory=5Fscope=5Fkeys=5Fupdated=5Fs?= =?UTF-8?q?ince=20=E6=96=B9=E6=B3=95=E5=8F=8A=E5=85=B6=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/storage/mod.rs | 71 ---------------------------------------------- 1 file changed, 71 deletions(-) diff --git a/src/storage/mod.rs b/src/storage/mod.rs index a209c33..ac7fb3b 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -779,31 +779,6 @@ impl SessionStore { Ok(scope_keys) } - pub fn list_memory_scope_keys_updated_since( - &self, - scope_kind: &str, - since_timestamp: i64, - ) -> Result, StorageError> { - let conn = self.conn.lock().expect("session db mutex poisoned"); - let mut stmt = conn.prepare( - " - SELECT DISTINCT scope_key - FROM memories - WHERE scope_kind = ?1 AND updated_at > ?2 - ORDER BY scope_key ASC - ", - )?; - - let rows = stmt.query_map(params![scope_kind, since_timestamp], |row| { - row.get::<_, String>(0) - })?; - let mut scope_keys = Vec::new(); - for row in rows { - scope_keys.push(row?); - } - Ok(scope_keys) - } - pub fn list_memories_for_scope( &self, scope_kind: &str, @@ -2368,50 +2343,4 @@ mod tests { assert_eq!(fetched.completed_at, Some(1_700_000_000_100)); } - #[test] - fn test_list_memory_scope_keys_updated_since_filters_recent_scopes() { - let store = SessionStore::in_memory().unwrap(); - - let first = store - .put_memory(&MemoryUpsert { - scope_kind: "user".to_string(), - scope_key: "feishu:user-1".to_string(), - namespace: "profile".to_string(), - memory_key: "work".to_string(), - content: "用户在做AI产品".to_string(), - source_type: "message".to_string(), - source_session_id: None, - source_message_id: None, - source_message_seq: None, - source_channel_name: None, - source_chat_id: None, - }) - .unwrap(); - - let cutoff = first.updated_at; - - std::thread::sleep(std::time::Duration::from_millis(2)); - - store - .put_memory(&MemoryUpsert { - scope_kind: "user".to_string(), - scope_key: "feishu:user-2".to_string(), - namespace: "preferences".to_string(), - memory_key: "style".to_string(), - content: "偏好简洁表达".to_string(), - source_type: "message".to_string(), - source_session_id: None, - source_message_id: None, - source_message_seq: None, - source_channel_name: None, - source_chat_id: None, - }) - .unwrap(); - - let recent_scope_keys = store - .list_memory_scope_keys_updated_since("user", cutoff) - .unwrap(); - - assert_eq!(recent_scope_keys, vec!["feishu:user-2".to_string()]); - } }