Skip to main content

Module task_query

Module task_query 

Source
Expand description

Pure filtering, grouping and counting for task queries.

Everything here is a function of its arguments: no clock, no filesystem, no shared state. run_query takes a snapshot of FileTasks (from crate::task_index::TaskIndex::snapshot) plus the day to treat as “today” and returns the whole response body. The axum handler is a thin wrapper, the same split SearchEngine::search / search_handler uses.

§Counting rules

The two display modes count very differently, and the difference is the whole reason grouping lives on the server:

ModeGrouptotal countsdone counts
Categoryone per fileevery task in the file, filters ignoredits Done ones
Calendarone per due buckettasks matching everything except statusits Done ones

Canceled tasks never count toward a total in either mode. In calendar mode they are dropped outright — they cannot appear, be counted, or create a bucket — because a canceled task has no meaningful due date.

Incomplete markers (crate::tasks::TaskKind::Marker) are category-mode only, dropped in calendar mode by the same rule and for a stronger reason: they can never carry a due date. They are real matches everywhere else — total_matches and the folder facets count them — but never move a note’s done/total, which FileTasks derives from checkboxes alone.

limit truncates the tasks that are returned; it never affects a count. total_matches is the pre-truncation number of matching tasks.

Structs§

FolderFacet
A folder and the number of matching tasks at or below it.
QueryTerms
The text filter, split into plain words and #tag tokens.
TaskGroup
One heading in the results list, with its tasks and progress numbers.
TaskHit
One task in a response: every Task field, plus where it lives.
TaskQuery
A task query, as posted to /.mbr/tasks.
TaskQueryResponse
The /.mbr/tasks response body.

Enums§

DueBucket
Which calendar heading a task falls under.
DueFilter
Due-date filter. Mirrors DueBucket so the filter and the calendar headings can never disagree about what “tomorrow” means.
IncludeFilter
Which kinds of entry a query wants back.
TaskMode
How results are grouped.

Constants§

DEFAULT_TASK_LIMIT
Default cap on returned tasks.

Functions§

due_bucket
Places a due datetime in its calendar bucket relative to today.
normalize_folder
Normalizes a folder filter to a /-delimited prefix, or None for “everywhere”.
parse_task_query
Splits a filter string into words and tags.
run_query
Runs a task query over an index snapshot.