search
query runs at most one parameterized SELECT per entity type that the query’s is: filters allow, and
returns the three result lists together.
struct Results
pub struct ResultsResults from a cross-entity search.
| Field | Type | Description |
|---|---|---|
artifacts |
Vec<artifact::Model> | Artifacts matching the query. |
iterations |
Vec<iteration::Model> | Iterations matching the query. |
tasks |
Vec<task::Model> | Tasks matching the query. |
fn query
pub async fn query(
conn: &Connection,
project_id: &Id,
parsed: &ParsedQuery,
show_all: bool,
) -> Result<Results, Error>Search across tasks, artifacts, and iterations using parsed query filters.
Translates ParsedQuery filters into SQL WHERE clauses:
is:filters scope which entity types are queriedtag:filters useEXISTSsubqueries onentity_tagsstatus:filters useIN/NOT INclauses- Free text uses
LIKEmatching on title and description/body show_all=falseexcludes resolved tasks, archived artifacts, and completed or cancelled iterations
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the database connection |
project_id |
&Id | the project to search |
parsed |
&ParsedQuery | the parsed query with its include and exclude filters and free text |
show_all |
bool | whether to keep resolved, archived and finished entities |
| returns | Result<Results, Error> | The matching tasks, artifacts and iterations, each list newest first and empty when its type is filtered out, or an error when a query or row decoding fails. |
fn wants_entity_type
fn wants_entity_type(parsed: &ParsedQuery, entity: &str) -> boolDetermine whether a given entity type should be included based on is: filters.
| Parameter | Type | Description |
|---|---|---|
parsed |
&ParsedQuery | the parsed query |
entity |
&str | the entity type name, such as task, artifact or iteration |
| returns | bool | false when the query has is: includes that do not name entity, or an is: exclude that does; true otherwise. |
struct QueryBuilder
struct QueryBuilderShared state for building a parameterized query.
| Field | Type | Description |
|---|---|---|
conditions |
Vec<String> | WHERE conditions, joined with AND; the first restricts to the project. |
params |
Vec<Value> | Positional parameter values, in the order of their ?N placeholders. |
idx |
usize | The number of the next ?N placeholder; starts at 2 because ?1 is the project id. |
QueryBuilder::new
fn new(project_id: &Id) -> SelfStart a builder whose only condition restricts rows to one project, bound as ?1.
| Parameter | Type | Description |
|---|---|---|
project_id |
&Id | the project to restrict to |
| returns | Self | A builder with the project condition and parameter, and the next placeholder number at 2. |
QueryBuilder::next_param
fn next_param(&mut self) -> usizeTake the next positional placeholder number and advance the counter.
| Parameter | Type | Description |
|---|---|---|
| returns | usize | The placeholder number to use as ?N. |
QueryBuilder::add_tag_includes
fn add_tag_includes(&mut self, parsed: &ParsedQuery, table: &str, entity_type: &str)Add tag include filters (OR-combined).
| Parameter | Type | Description |
|---|---|---|
parsed |
&ParsedQuery | the parsed query whose tag: includes are read |
table |
&str | the SQL table of the searched entity, used to correlate the subquery |
entity_type |
&str | the entity_tags.entity_type value of that entity |
QueryBuilder::add_tag_excludes
fn add_tag_excludes(&mut self, parsed: &ParsedQuery, table: &str, entity_type: &str)Add tag exclude filters (AND-combined).
| Parameter | Type | Description |
|---|---|---|
parsed |
&ParsedQuery | the parsed query whose tag: excludes are read |
table |
&str | the SQL table of the searched entity, used to correlate the subquery |
entity_type |
&str | the entity_tags.entity_type value of that entity |
QueryBuilder::add_status_includes
fn add_status_includes(&mut self, parsed: &ParsedQuery)Add status include filters (OR-combined via IN).
| Parameter | Type | Description |
|---|---|---|
parsed |
&ParsedQuery | the parsed query whose status: includes are read |
QueryBuilder::add_status_excludes
fn add_status_excludes(&mut self, parsed: &ParsedQuery)Add status exclude filters (AND-combined via NOT IN).
| Parameter | Type | Description |
|---|---|---|
parsed |
&ParsedQuery | the parsed query whose status: excludes are read |
QueryBuilder::add_text_filter
fn add_text_filter(&mut self, parsed: &ParsedQuery, text_columns: &[&str])Add free text filter (title LIKE OR description/body LIKE).
The query’s text words are joined with spaces and matched as one substring.
| Parameter | Type | Description |
|---|---|---|
parsed |
&ParsedQuery | the parsed query whose free text is read |
text_columns |
&[&str] | the columns to match with LIKE, any of which may match |
fn query_artifacts
async fn query_artifacts(
conn: &Connection,
project_id: &Id,
parsed: &ParsedQuery,
show_all: bool,
) -> Result<Vec<artifact::Model>, Error>Find the project’s artifacts that match the query’s tag and text filters.
Artifacts have no status, so any status: include yields no artifacts and status: excludes are ignored.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the database connection |
project_id |
&Id | the project to search |
parsed |
&ParsedQuery | the parsed query |
show_all |
bool | whether to keep archived artifacts |
| returns | Result<Vec<artifact::Model>, Error> | The matching artifacts, newest first, or an error when the query or row decoding fails. |
fn query_iterations
async fn query_iterations(
conn: &Connection,
project_id: &Id,
parsed: &ParsedQuery,
show_all: bool,
) -> Result<Vec<iteration::Model>, Error>Find the project’s iterations that match the query’s tag, status and text filters.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the database connection |
project_id |
&Id | the project to search |
parsed |
&ParsedQuery | the parsed query |
show_all |
bool | whether to keep completed and cancelled iterations |
| returns | Result<Vec<iteration::Model>, Error> | The matching iterations, newest first, or an error when the query or row decoding fails. |
fn query_tasks
async fn query_tasks(
conn: &Connection,
project_id: &Id,
parsed: &ParsedQuery,
show_all: bool,
) -> Result<Vec<task::Model>, Error>Find the project’s tasks that match the query’s tag, status and text filters.
| Parameter | Type | Description |
|---|---|---|
conn |
&Connection | the database connection |
project_id |
&Id | the project to search |
parsed |
&ParsedQuery | the parsed query |
show_all |
bool | whether to keep resolved tasks |
| returns | Result<Vec<task::Model>, Error> | The matching tasks, newest first, or an error when the query or row decoding fails. |