feat: Add 'bd count' command for counting and grouping issues
Implements a new 'bd count' command that provides efficient issue counting with filtering and grouping capabilities. Features: - Basic count: Returns total count of issues matching filters - All filtering options from 'bd list' (status, priority, type, assignee, labels, dates, etc.) - Grouping via --by-* flags: status, priority, type, assignee, label - JSON output support for both simple and grouped counts - Both daemon and direct mode support Implementation: - Added OpCount operation and CountArgs to RPC protocol - Added Count() method to RPC client - Implemented handleCount() server-side handler with optimized bulk label fetching - Created cmd/bd/count.go with full CLI implementation Performance optimization: - Pre-fetches all labels in a single query when using --by-label to avoid N+1 queries 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ const (
|
||||
OpUpdate = "update"
|
||||
OpClose = "close"
|
||||
OpList = "list"
|
||||
OpCount = "count"
|
||||
OpShow = "show"
|
||||
OpReady = "ready"
|
||||
OpStale = "stale"
|
||||
@@ -127,6 +128,44 @@ type ListArgs struct {
|
||||
PriorityMax *int `json:"priority_max,omitempty"`
|
||||
}
|
||||
|
||||
// CountArgs represents arguments for the count operation
|
||||
type CountArgs struct {
|
||||
// Supports all the same filters as ListArgs
|
||||
Query string `json:"query,omitempty"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Priority *int `json:"priority,omitempty"`
|
||||
IssueType string `json:"issue_type,omitempty"`
|
||||
Assignee string `json:"assignee,omitempty"`
|
||||
Labels []string `json:"labels,omitempty"`
|
||||
LabelsAny []string `json:"labels_any,omitempty"`
|
||||
IDs []string `json:"ids,omitempty"`
|
||||
|
||||
// Pattern matching
|
||||
TitleContains string `json:"title_contains,omitempty"`
|
||||
DescriptionContains string `json:"description_contains,omitempty"`
|
||||
NotesContains string `json:"notes_contains,omitempty"`
|
||||
|
||||
// Date ranges
|
||||
CreatedAfter string `json:"created_after,omitempty"`
|
||||
CreatedBefore string `json:"created_before,omitempty"`
|
||||
UpdatedAfter string `json:"updated_after,omitempty"`
|
||||
UpdatedBefore string `json:"updated_before,omitempty"`
|
||||
ClosedAfter string `json:"closed_after,omitempty"`
|
||||
ClosedBefore string `json:"closed_before,omitempty"`
|
||||
|
||||
// Empty/null checks
|
||||
EmptyDescription bool `json:"empty_description,omitempty"`
|
||||
NoAssignee bool `json:"no_assignee,omitempty"`
|
||||
NoLabels bool `json:"no_labels,omitempty"`
|
||||
|
||||
// Priority range
|
||||
PriorityMin *int `json:"priority_min,omitempty"`
|
||||
PriorityMax *int `json:"priority_max,omitempty"`
|
||||
|
||||
// Grouping option (only one can be specified)
|
||||
GroupBy string `json:"group_by,omitempty"` // "status", "priority", "type", "assignee", "label"
|
||||
}
|
||||
|
||||
// ShowArgs represents arguments for the show operation
|
||||
type ShowArgs struct {
|
||||
ID string `json:"id"`
|
||||
|
||||
Reference in New Issue
Block a user