filter

package
v0.0.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsDurationLiteral

func IsDurationLiteral(s string) bool

IsDurationLiteral checks if a string is a valid duration literal

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration literal like "24hour" or "1week"

Types

type BinaryExpr

type BinaryExpr struct {
	Op    string // "AND", "OR"
	Left  FilterExpr
	Right FilterExpr
}

BinaryExpr represents AND, OR operations

func (*BinaryExpr) Evaluate

func (b *BinaryExpr) Evaluate(task *task.Task, now time.Time, currentUser string) bool

Evaluate implements FilterExpr

type CompareExpr

type CompareExpr struct {
	Field string      // "status", "type", "assignee", "priority", "points", "createdat", "updatedat", "tags"
	Op    string      // "=", "==", "!=", ">", "<", ">=", "<="
	Value interface{} // string, int, or TimeExpr
}

CompareExpr represents comparisons like status = 'ready' or Priority < 3

func (*CompareExpr) Evaluate

func (c *CompareExpr) Evaluate(task *task.Task, now time.Time, currentUser string) bool

Evaluate implements FilterExpr for CompareExpr

type DurationValue

type DurationValue struct {
	Duration time.Duration
}

DurationValue represents a parsed duration for comparison

type FilterExpr

type FilterExpr interface {
	Evaluate(task *task.Task, now time.Time, currentUser string) bool
}

FilterExpr represents a filter expression that can be evaluated against a task

func ParseFilter

func ParseFilter(expr string) (FilterExpr, error)

ParseFilter parses a filter expression string into an AST. This is the main public entry point for filter parsing.

Example expressions:

  • status = 'done'
  • type = 'bug' AND priority > 2
  • status IN ['ready', 'in_progress']
  • NOW - CreatedAt < 24hour
  • (status = 'ready' OR status = 'in_progress') AND priority >= 3

Returns nil expression for empty string (no filtering).

type InExpr

type InExpr struct {
	Field  string        // "status", "type", "tags", etc.
	Not    bool          // true for NOT IN, false for IN
	Values []interface{} // List of values to check against (strings, ints, etc.)
}

InExpr represents IN/NOT IN operations like: tags IN ['ui', 'charts', 'viz']

func (*InExpr) Evaluate

func (i *InExpr) Evaluate(task *task.Task, now time.Time, currentUser string) bool

Evaluate implements FilterExpr for InExpr

type TimeExpr

type TimeExpr struct {
	Base    string      // "NOW", "CreatedAt", "UpdatedAt"
	Op      string      // "+", "-"
	Operand interface{} // time.Duration or field name string
}

TimeExpr represents time arithmetic like NOW - 24hour or NOW - CreatedAt

func (*TimeExpr) Evaluate

func (t *TimeExpr) Evaluate(task *task.Task, now time.Time) interface{}

Evaluate returns the computed time or duration value

type Token

type Token struct {
	Type  TokenType
	Value string
}

Token represents a lexer token

func Tokenize

func Tokenize(expr string) ([]Token, error)

Tokenize breaks the expression into tokens

type TokenType

type TokenType int

TokenType represents the type of a lexer token

const (
	TokenEOF      TokenType = iota
	TokenIdent              // field names like status, type, NOW, CURRENT_USER
	TokenString             // 'value' or "value"
	TokenNumber             // integer literals
	TokenDuration           // 24hour, 1week, etc.
	TokenOperator           // =, ==, !=, >, <, >=, <=, +, -
	TokenAnd
	TokenOr
	TokenNot
	TokenIn    // IN keyword
	TokenNotIn // NOT IN keyword combination
	TokenLParen
	TokenRParen
	TokenLBracket // [ for list literals
	TokenRBracket // ] for list literals
	TokenComma    // , for list elements
)

type UnaryExpr

type UnaryExpr struct {
	Op   string // "NOT"
	Expr FilterExpr
}

UnaryExpr represents NOT operation

func (*UnaryExpr) Evaluate

func (u *UnaryExpr) Evaluate(task *task.Task, now time.Time, currentUser string) bool

Evaluate implements FilterExpr

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL