mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-21 00:49:54 +01:00
fix: sorting of conv lists, streaming responses
This commit is contained in:
@@ -423,7 +423,7 @@ impl User {
|
||||
.client
|
||||
.query(
|
||||
"SELECT * FROM type::table($table_name) WHERE user_id = $user_id
|
||||
ORDER BY updated_at DESC",
|
||||
ORDER BY created_at DESC",
|
||||
)
|
||||
.bind(("table_name", Conversation::table_name()))
|
||||
.bind(("user_id", user_id.to_string()))
|
||||
@@ -789,7 +789,7 @@ mod tests {
|
||||
for i in 0..5 {
|
||||
let mut conv = Conversation::new(user_id.to_string(), format!("Conv {}", i));
|
||||
// Fake updated_at i minutes apart
|
||||
conv.updated_at = chrono::Utc::now() - chrono::Duration::minutes(i);
|
||||
conv.created_at = chrono::Utc::now() - chrono::Duration::minutes(i);
|
||||
db.store_item(conv.clone())
|
||||
.await
|
||||
.expect("Failed to store conversation");
|
||||
@@ -806,13 +806,13 @@ mod tests {
|
||||
for window in retrieved.windows(2) {
|
||||
// Assert each earlier conversation has updated_at >= later conversation
|
||||
assert!(
|
||||
window[0].updated_at >= window[1].updated_at,
|
||||
"Conversations not ordered descending by updated_at"
|
||||
window[0].created_at >= window[1].created_at,
|
||||
"Conversations not ordered descending by created_at"
|
||||
);
|
||||
}
|
||||
|
||||
// (Optional) Check first conversation title matches the most recently updated
|
||||
let most_recent = conversations.iter().max_by_key(|c| c.updated_at).unwrap();
|
||||
// Check first conversation title matches the most recently updated
|
||||
let most_recent = conversations.iter().max_by_key(|c| c.created_at).unwrap();
|
||||
assert_eq!(retrieved[0].id, most_recent.id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user