Skip to main content

TaskFilter

Enum TaskFilter 

Source
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 tasks
  • Date: 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 tag
  • ByTags: Tasks associated with multiple tags (intersection)

§Query Optimization

Different filter types have different performance characteristics:

  • All: Fastest, no WHERE clause needed
  • ByIds: Very fast with proper indexing
  • Date: Fast with timestamp indexing
  • Incomplete: Moderate speed, depends on data distribution
  • ByTag/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 15
§

ByTag(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 tags

Trait Implementations§

Source§

impl Clone for TaskFilter

Source§

fn clone(&self) -> TaskFilter

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TaskFilter

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more