filter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2026 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package filter provides composable SQL clause builders for querying tasks. Filters compose with AND semantics by default; use Or for OR semantics.

Virtual tag registry. New tags are registered via init() in virtual_*.go category files. This file never needs to change when adding new tags.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildTaskQuery

func BuildTaskQuery(filters ...Filter) (string, []any)

BuildTaskQuery assembles a full SELECT against the tasks table with all provided filters ANDed together. With no filters it returns all tasks.

func ComputeVirtualTags

func ComputeVirtualTags(task *taskkit.Task, now time.Time) []string

ComputeVirtualTags returns the names of all virtual tags that apply to task, sorted alphabetically. Called at the client layer after full hydration.

func IsVirtualTag

func IsVirtualTag(name string) bool

IsVirtualTag reports whether name is a registered virtual tag. The lookup is exact - virtual tag names are uppercase by convention.

Types

type Clause

type Clause struct {
	SQL    string
	Params []any
}

Clause holds a SQL fragment and its bound parameters.

type Filter

type Filter func() Clause

Filter is a function that returns a Clause.

func BlockedBy

func BlockedBy(dependsOnID string) Filter

BlockedBy matches tasks that are blocked by the given task ID.

func Blocking

func Blocking(taskID string) Filter

Blocking matches tasks that are blocking the given task ID.

func CreatedAfter

func CreatedAfter(t time.Time) Filter

CreatedAfter matches tasks created after t.

func CreatedBefore

func CreatedBefore(t time.Time) Filter

CreatedBefore matches tasks created before t. Since task_id is a ULID, lexicographic comparison is equivalent to time comparison.

func DeadlineAfter

func DeadlineAfter(t time.Time) Filter

DeadlineAfter matches tasks whose deadline is after t.

func DeadlineBefore

func DeadlineBefore(t time.Time) Filter

DeadlineBefore matches tasks whose deadline is before t.

func DescriptionContains

func DescriptionContains(s string) Filter

DescriptionContains matches tasks whose description contains s (case-insensitive).

func DescriptionIs

func DescriptionIs(s string) Filter

DescriptionIs matches tasks whose description exactly equals s.

func DisplayID

func DisplayID(id int) Filter

DisplayID matches the active task with the given display ID.

func HasDeadline

func HasDeadline() Filter

HasDeadline matches tasks with a deadline set.

func HasProject

func HasProject() Filter

HasProject matches tasks that have any project set.

func HasScheduled

func HasScheduled() Filter

HasScheduled matches tasks with a scheduled date set.

func HasTag

func HasTag(tag string) Filter

HasTag matches tasks that have the given tag, or whose state matches the named virtual tag if the name is registered (e.g. "BLOCKED", "OVERDUE"). Virtual tag names are uppercase by convention; "blocked" still matches the stored tag.

func HasWait

func HasWait() Filter

HasWait matches tasks with a wait date set.

func ID

func ID(id string) Filter

ID matches the task with the given ULID string.

func LacksTag

func LacksTag(tag string) Filter

LacksTag matches tasks that do not have the given tag, or whose state does not match the named virtual tag if the name is registered.

func ModifiedAfter

func ModifiedAfter(t time.Time) Filter

ModifiedAfter matches tasks whose most recent history entry is after t.

func ModifiedBefore

func ModifiedBefore(t time.Time) Filter

ModifiedBefore matches tasks whose most recent history entry is before t.

func NoDeadline

func NoDeadline() Filter

NoDeadline matches tasks with no deadline set.

func NoProject

func NoProject() Filter

NoProject matches tasks with no project set.

func NoScheduled

func NoScheduled() Filter

NoScheduled matches tasks with no scheduled date set.

func NoWait

func NoWait() Filter

NoWait matches tasks with no wait date set.

func Or

func Or(filters ...Filter) Filter

Or combines one or more filters with OR semantics.

func Project

func Project(name string) Filter

Project matches tasks belonging to the named project.

func ProjectPrefix

func ProjectPrefix(prefix string) Filter

ProjectPrefix matches tasks whose project name starts with prefix.

func ScheduledAfter

func ScheduledAfter(t time.Time) Filter

ScheduledAfter matches tasks whose scheduled date is after t.

func ScheduledBefore

func ScheduledBefore(t time.Time) Filter

ScheduledBefore matches tasks whose scheduled date is before t.

func Status

func Status(s taskkit.Status) Filter

Status matches tasks with the given status.

func StatusAny

func StatusAny(statuses ...taskkit.Status) Filter

StatusAny matches tasks whose status is one of the provided values.

func WaitAfter

func WaitAfter(t time.Time) Filter

WaitAfter matches tasks whose wait date is after t.

func WaitBefore

func WaitBefore(t time.Time) Filter

WaitBefore matches tasks whose wait date is before t.

Jump to

Keyboard shortcuts

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