pub enum TaskFilter {
All,
Date(NaiveDate),
Incomplete,
ByIds(Vec<i32>),
ByTag(String),
ByTags(Vec<String>),
}Expand description
Enumeration of available task filtering criteria for database queries.
This enum provides a type-safe way to specify different filtering options when querying tasks from the database. It supports simple filters as well as complex multi-criteria filtering for advanced task management workflows.
§Filter Categories
§Scope Filters
All: No filtering, returns all tasksDate: Time-based filtering for specific dates
§Status Filters
Incomplete: Tasks with progress less than 100%
§Identity Filters
ByIds: Specific tasks by their database IDs
§Categorization Filters
ByTag: Tasks associated with a single tagByTags: Tasks associated with multiple tags (intersection)
§Query Optimization
Different filter types have different performance characteristics:
All: Fastest, no WHERE clause neededByIds: Very fast with proper indexingDate: Fast with timestamp indexingIncomplete: Moderate speed, depends on data distributionByTag/ByTags: Moderate speed, requires JOIN operations
§Examples Usage
use kasl::libs::task::TaskFilter;
use chrono::Local;
// Get all tasks
let all_tasks_filter = TaskFilter::All;
// Get today's tasks
let today = Local::now().date_naive();
let today_filter = TaskFilter::Date(today);
// Get incomplete tasks
let incomplete_filter = TaskFilter::Incomplete;
// Get specific tasks
let specific_filter = TaskFilter::ByIds(vec![1, 2, 3]);
// Get tagged tasks
let tagged_filter = TaskFilter::ByTag("urgent".to_string());
let multi_tagged_filter = TaskFilter::ByTags(vec![
"frontend".to_string(),
"javascript".to_string()
]);Variants§
All
Returns all tasks without any filtering restrictions.
This filter retrieves the complete task collection from the database. Itâs the most efficient filter type since it doesnât require any WHERE clauses or complex query conditions.
Use Cases:
- Complete task listings for administrative purposes
- Full data exports and backups
- Global task analysis and reporting
- Initial load for client-side filtering
Performance: Excellent - simple SELECT query
Date(NaiveDate)
Returns tasks created or modified on the specified date.
This filter uses the task timestamp to find tasks associated with a particular date. The filtering is typically done at the day level, including all tasks from 00:00:00 to 23:59:59 on the specified date.
Use Cases:
- Daily task reviews and reports
- Time-based productivity analysis
- Date-specific task exports
- Calendar integration and scheduling
Performance: Good - benefits from timestamp indexing
Example:
use kasl::libs::task::TaskFilter;
use chrono::{Local, NaiveDate};
let today = Local::now().date_naive();
let filter = TaskFilter::Date(today);Incomplete
Returns tasks with completion percentage less than 100%.
This filter identifies tasks that are still in progress or havenât been started. Itâs useful for focusing on active work items and identifying tasks that need attention.
Criteria:
- Tasks with
completeness< 100 - Tasks with
completeness= None (treated as incomplete)
Use Cases:
- Active work item management
- Progress tracking and follow-up
- Workload planning and estimation
- Focus mode filtering for current work
Performance: Moderate - depends on completion data distribution
Example:
use kasl::libs::task::TaskFilter;
let incomplete_filter = TaskFilter::Incomplete;
// Returns tasks with completeness: None, Some(0), Some(50), etc.
// Excludes tasks with completeness: Some(100)ByIds(Vec<i32>)
Returns specific tasks identified by their database IDs.
This filter provides precise task retrieval when the exact task identifiers are known. Itâs the most efficient way to retrieve a known set of tasks and is commonly used for bulk operations.
Use Cases:
- Bulk task operations (update, delete, export)
- User-selected task collections
- Related task loading (parent/child relationships)
- API responses for specific task requests
Performance: Excellent - uses primary key indexing
Example:
use kasl::libs::task::TaskFilter;
let specific_tasks = TaskFilter::ByIds(vec![1, 5, 10, 15]);
// Returns only tasks with IDs 1, 5, 10, and 15ByTag(String)
Returns tasks associated with the specified tag.
This filter finds all tasks that have been tagged with a particular label. Itâs useful for category-based task management and organizing work by project, priority, or skill area.
Query Method:
- Performs JOIN with task_tags relationship table
- Matches tag name case-sensitively
- Returns tasks with at least one matching tag
Use Cases:
- Project-specific task listings
- Priority-based filtering (âurgentâ, âlow-priorityâ)
- Skill-based work organization (âjavascriptâ, âdatabaseâ)
- Status-based filtering (âblockedâ, âwaiting-reviewâ)
Performance: Moderate - requires JOIN operation
Example:
use kasl::libs::task::TaskFilter;
let urgent_filter = TaskFilter::ByTag("urgent".to_string());
// Returns all tasks tagged with "urgent"ByTags(Vec<String>)
Returns tasks associated with all of the specified tags.
This filter finds tasks that have been tagged with every tag in the provided list (intersection, not union). Itâs useful for finding tasks that meet multiple criteria simultaneously.
Query Method:
- Performs multiple JOINs with task_tags table
- Requires ALL tags to be present on the task
- More restrictive than single tag filtering
Use Cases:
- Complex filtering (âfrontendâ AND âurgentâ AND âjavascriptâ)
- Multi-criteria task discovery
- Advanced search functionality
- Refined project management workflows
Performance: Moderate to Slow - multiple JOINs required
Example:
use kasl::libs::task::TaskFilter;
let complex_filter = TaskFilter::ByTags(vec![
"frontend".to_string(),
"urgent".to_string(),
"javascript".to_string()
]);
// Returns tasks that have ALL three tagsTrait Implementations§
Source§impl Clone for TaskFilter
impl Clone for TaskFilter
Source§fn clone(&self) -> TaskFilter
fn clone(&self) -> TaskFilter
1.0.0 (const: unstable) ¡ Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more