Documentation
¶
Overview ¶
Package query implements a simple query language for filtering beads.
The query language supports:
- Field comparisons: status=open, priority>1, updated>7d
- Boolean operators: AND, OR, NOT
- Parentheses for grouping: (status=open OR status=blocked) AND priority<2
- Date-relative expressions: updated>7d, created<30d
Example queries:
- status=open AND priority>1
- (status=open OR status=blocked) AND updated>7d
- NOT status=closed
- type=bug AND priority=0
Index ¶
Constants ¶
This section is empty.
Variables ¶
var KnownFields = map[string]bool{ "id": true, "title": true, "description": true, "desc": true, "status": true, "priority": true, "type": true, "assignee": true, "owner": true, "created": true, "updated": true, "closed": true, "created_at": true, "updated_at": true, "closed_at": true, "label": true, "labels": true, "pinned": true, "ephemeral": true, "template": true, "spec": true, "spec_id": true, "parent": true, "mol_type": true, "notes": true, "has_metadata_key": true, }
KnownFields lists fields that can be queried.
Functions ¶
This section is empty.
Types ¶
type ComparisonNode ¶
type ComparisonNode struct {
Field string
Op ComparisonOp
Value string
ValueType TokenType // TokenIdent, TokenString, TokenNumber, or TokenDuration
}
ComparisonNode represents a field comparison (e.g., status=open).
func (*ComparisonNode) String ¶
func (n *ComparisonNode) String() string
type ComparisonOp ¶
type ComparisonOp int
ComparisonOp represents a comparison operator.
const ( OpEquals ComparisonOp = iota OpNotEquals OpLess OpLessEq OpGreater OpGreaterEq )
func (ComparisonOp) String ¶
func (op ComparisonOp) String() string
String returns the string representation of a ComparisonOp.
type Evaluator ¶
type Evaluator struct {
// contains filtered or unexported fields
}
Evaluator converts a query AST to an IssueFilter and/or predicate function.
func NewEvaluator ¶
NewEvaluator creates a new Evaluator with the given reference time.
type Lexer ¶
type Lexer struct {
// contains filtered or unexported fields
}
Lexer tokenizes a query string.
type Node ¶
type Node interface {
String() string
// contains filtered or unexported methods
}
Node represents a node in the query AST.
type Parser ¶
type Parser struct {
// contains filtered or unexported fields
}
Parser parses a query string into an AST.
type QueryResult ¶
type QueryResult struct {
// Filter contains filters that can be passed to SearchIssues.
// This is always populated with at least base filters.
Filter types.IssueFilter
// Predicate is a function that evaluates whether an issue matches the query.
// If nil, the Filter alone is sufficient.
// If non-nil, issues matching Filter should be further filtered by Predicate.
Predicate func(*types.Issue) bool
// RequiresPredicate indicates if in-memory filtering is needed.
// True when the query contains OR or complex NOT expressions.
RequiresPredicate bool
}
QueryResult contains the result of evaluating a query. For simple queries, Filter will be populated and Predicate will be nil. For complex queries with OR, Predicate will be set and Filter will contain base filters that can pre-filter issues.
func Evaluate ¶
func Evaluate(query string) (*QueryResult, error)
Evaluate is a convenience function that parses and evaluates a query string.
func EvaluateAt ¶
func EvaluateAt(query string, now time.Time) (*QueryResult, error)
EvaluateAt parses and evaluates a query string with a specific reference time.
type TokenType ¶
type TokenType int
TokenType represents the type of a lexer token.
const ( TokenEOF TokenType = iota TokenIdent // field names, values TokenString // quoted strings TokenNumber // numeric values TokenDuration // duration values like 7d, 24h TokenEquals // = TokenNotEquals // != TokenLess // < TokenLessEq // <= TokenGreater // > TokenGreaterEq // >= TokenAnd // AND TokenOr // OR TokenNot // NOT TokenLParen // ( TokenRParen // ) TokenComma // , (for lists) )