Fix bd gate list: Separate closed gates into own section
Previously, displayGates() always showed 'Open Gates' header even when closed gates were included via --all flag. Also, closed gates would appear mixed with open gates under the misleading 'Open Gates' header. Changes: - Modified displayGates() to accept showAll parameter - Separates gates into 'Open Gates' and 'Closed Gates' sections - Closed gates only shown when --all flag is used - Fixed handleGateList RPC handler to use ExcludeStatus instead of Status filter for consistency with CLI behavior Fixes gas-town issue go-47m
This commit is contained in:
@@ -101,7 +101,7 @@ By default, shows only open gates. Use --all to include closed gates.`,
|
||||
return
|
||||
}
|
||||
|
||||
displayGates(issues)
|
||||
displayGates(issues, allFlag)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -117,20 +117,53 @@ By default, shows only open gates. Use --all to include closed gates.`,
|
||||
return
|
||||
}
|
||||
|
||||
displayGates(issues)
|
||||
displayGates(issues, allFlag)
|
||||
},
|
||||
}
|
||||
|
||||
// displayGates formats and displays gate issues
|
||||
func displayGates(gates []*types.Issue) {
|
||||
// displayGates formats and displays gate issues, separating open and closed gates
|
||||
func displayGates(gates []*types.Issue, showAll bool) {
|
||||
if len(gates) == 0 {
|
||||
fmt.Println("No gates found.")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("\n%s Open Gates (%d):\n\n", ui.RenderAccent("⏳"), len(gates))
|
||||
|
||||
// Separate open and closed gates
|
||||
var openGates, closedGates []*types.Issue
|
||||
for _, gate := range gates {
|
||||
if gate.Status == types.StatusClosed {
|
||||
closedGates = append(closedGates, gate)
|
||||
} else {
|
||||
openGates = append(openGates, gate)
|
||||
}
|
||||
}
|
||||
|
||||
// Display open gates
|
||||
if len(openGates) > 0 {
|
||||
fmt.Printf("\n%s Open Gates (%d):\n\n", ui.RenderAccent("⏳"), len(openGates))
|
||||
for _, gate := range openGates {
|
||||
displaySingleGate(gate)
|
||||
}
|
||||
}
|
||||
|
||||
// Display closed gates only if --all was used
|
||||
if showAll && len(closedGates) > 0 {
|
||||
fmt.Printf("\n%s Closed Gates (%d):\n\n", ui.RenderMuted("●"), len(closedGates))
|
||||
for _, gate := range closedGates {
|
||||
displaySingleGate(gate)
|
||||
}
|
||||
}
|
||||
|
||||
if len(openGates) == 0 && (!showAll || len(closedGates) == 0) {
|
||||
fmt.Println("No gates found.")
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("To resolve a gate: bd close <gate-id>\n")
|
||||
}
|
||||
|
||||
// displaySingleGate formats and displays a single gate issue
|
||||
func displaySingleGate(gate *types.Issue) {
|
||||
statusSym := "○"
|
||||
if gate.Status == types.StatusClosed {
|
||||
statusSym = "●"
|
||||
@@ -164,9 +197,6 @@ func displayGates(gates []*types.Issue) {
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
fmt.Printf("To resolve a gate: bd close <gate-id>\n")
|
||||
}
|
||||
|
||||
// gateAddWaiterCmd adds a waiter to a gate
|
||||
var gateAddWaiterCmd = &cobra.Command{
|
||||
Use: "add-waiter <gate-id> <waiter>",
|
||||
|
||||
@@ -2108,9 +2108,9 @@ func (s *Server) handleGateList(req *Request) Response {
|
||||
filter := types.IssueFilter{
|
||||
IssueType: &gateType,
|
||||
}
|
||||
// By default, exclude closed gates (consistent with CLI behavior)
|
||||
if !args.All {
|
||||
openStatus := types.StatusOpen
|
||||
filter.Status = &openStatus
|
||||
filter.ExcludeStatus = []types.Status{types.StatusClosed}
|
||||
}
|
||||
|
||||
gates, err := store.SearchIssues(ctx, "", filter)
|
||||
|
||||
Reference in New Issue
Block a user