Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions crates/forge_infra/src/database/repository/conversation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ impl ConversationRepository for ConversationRepositoryImpl {
let workspace_id = self.wid.id() as i64;
let mut query = conversations::table
.filter(conversations::workspace_id.eq(&workspace_id))
.order(conversations::created_at.desc())
.filter(conversations::context.is_not_null())
.order(conversations::updated_at.desc())
Comment on lines +118 to +119

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title indicates this change is about sorting conversations by updated_at, but the implementation also adds a filter for non-null contexts. This additional filter could potentially exclude conversations that were previously included in the results.

Consider whether:

  1. The filter is an intentional change that should be mentioned in the PR description
  2. The filter is necessary for the sorting change to work correctly
  3. The filter should be removed if it's not part of the intended change

The tests have been updated to include contexts in all test conversations, which suggests this might be intentional, but it would be helpful to clarify the purpose of this additional filter in the PR description.

Suggested change
.filter(conversations::context.is_not_null())
.order(conversations::updated_at.desc())
.order(conversations::updated_at.desc())

Spotted by Diamond

Fix in Graphite


Is this helpful? React πŸ‘ or πŸ‘Ž to let us know.

.into_boxed();

if let Some(limit_value) = limit {
Expand Down Expand Up @@ -211,10 +212,14 @@ mod tests {

#[tokio::test]
async fn test_find_all_conversations() -> anyhow::Result<()> {
let context1 = Context::default().messages(vec![ContextMessage::user("Hello", None)]);
let context2 = Context::default().messages(vec![ContextMessage::user("World", None)]);
let conversation1 = Conversation::new(ConversationId::generate())
.title(Some("Test Conversation".to_string()));
.title(Some("Test Conversation".to_string()))
.context(Some(context1));
let conversation2 = Conversation::new(ConversationId::generate())
.title(Some("Second Conversation".to_string()));
.title(Some("Second Conversation".to_string()))
.context(Some(context2));
let repo = repository()?;

repo.upsert_conversation(conversation1.clone()).await?;
Expand All @@ -230,9 +235,12 @@ mod tests {

#[tokio::test]
async fn test_find_all_conversations_with_limit() -> anyhow::Result<()> {
let context1 = Context::default().messages(vec![ContextMessage::user("Hello", None)]);
let context2 = Context::default().messages(vec![ContextMessage::user("World", None)]);
let conversation1 = Conversation::new(ConversationId::generate())
.title(Some("Test Conversation".to_string()));
let conversation2 = Conversation::new(ConversationId::generate());
.title(Some("Test Conversation".to_string()))
.context(Some(context1));
let conversation2 = Conversation::new(ConversationId::generate()).context(Some(context2));
let repo = repository()?;

repo.upsert_conversation(conversation1).await?;
Expand Down
Loading