feat: add --unassigned flag to bd ready command
Adds the ability to filter ready work for issues with no assignee, which is useful for the SCAVENGE protocol in Gas Town where polecats need to query the "Salvage Yard" for unclaimed work. Changes: - Add Unassigned bool field to types.WorkFilter - Add --unassigned/-u flag to bd ready command - Update SQL query in GetReadyWork to filter for NULL/empty assignee - Add Unassigned field to RPC ReadyArgs for daemon support - Add tests for the new functionality Closes: gt-3rp 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -29,7 +29,9 @@ func (s *SQLiteStorage) GetReadyWork(ctx context.Context, filter types.WorkFilte
|
||||
args = append(args, *filter.Priority)
|
||||
}
|
||||
|
||||
if filter.Assignee != nil {
|
||||
if filter.Unassigned {
|
||||
whereClauses = append(whereClauses, "(i.assignee IS NULL OR i.assignee = '')")
|
||||
} else if filter.Assignee != nil {
|
||||
whereClauses = append(whereClauses, "i.assignee = ?")
|
||||
args = append(args, *filter.Assignee)
|
||||
}
|
||||
|
||||
@@ -168,6 +168,40 @@ func TestGetReadyWorkWithAssigneeFilter(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetReadyWorkWithUnassignedFilter(t *testing.T) {
|
||||
store, cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
// Create issues with different assignees
|
||||
issueAlice := &types.Issue{Title: "Alice's task", Status: types.StatusOpen, Priority: 1, IssueType: types.TypeTask, Assignee: "alice"}
|
||||
issueBob := &types.Issue{Title: "Bob's task", Status: types.StatusOpen, Priority: 1, IssueType: types.TypeTask, Assignee: "bob"}
|
||||
issueUnassigned := &types.Issue{Title: "Unassigned", Status: types.StatusOpen, Priority: 1, IssueType: types.TypeTask}
|
||||
|
||||
store.CreateIssue(ctx, issueAlice, "test-user")
|
||||
store.CreateIssue(ctx, issueBob, "test-user")
|
||||
store.CreateIssue(ctx, issueUnassigned, "test-user")
|
||||
|
||||
// Filter for unassigned issues
|
||||
ready, err := store.GetReadyWork(ctx, types.WorkFilter{Status: types.StatusOpen, Unassigned: true})
|
||||
if err != nil {
|
||||
t.Fatalf("GetReadyWork with unassigned filter failed: %v", err)
|
||||
}
|
||||
|
||||
if len(ready) != 1 {
|
||||
t.Fatalf("Expected 1 unassigned issue, got %d", len(ready))
|
||||
}
|
||||
|
||||
if ready[0].Assignee != "" {
|
||||
t.Errorf("Expected unassigned issue, got assignee %q", ready[0].Assignee)
|
||||
}
|
||||
|
||||
if ready[0].ID != issueUnassigned.ID {
|
||||
t.Errorf("Expected issue %s, got %s", issueUnassigned.ID, ready[0].ID)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetReadyWorkWithLimit(t *testing.T) {
|
||||
store, cleanup := setupTestDB(t)
|
||||
defer cleanup()
|
||||
|
||||
Reference in New Issue
Block a user