Limit Filter "universes" to invocation::filter

Universes are really an optimization of filtering tasks, so let's define
them there, and derive them from the set of conditions.  This means that
complex filters might get missed and end up doing a full task scan, but
that's probably OK.

Note that this does not fix the working-set API issues (#108 and #123).
This commit is contained in:
Dustin J. Mitchell
2020-12-30 00:23:18 +00:00
parent 0a458b5f5b
commit fc977a0fe6
5 changed files with 236 additions and 147 deletions

View File

@@ -1,11 +1,11 @@
use crate::argparse::Filter;
use crate::argparse::{Condition, Filter};
use crate::invocation::filtered_tasks;
use crate::report::{Column, Property, Report, Sort, SortBy};
use crate::table;
use failure::{bail, Fallible};
use prettytable::{Row, Table};
use std::cmp::Ordering;
use taskchampion::{Replica, Task, Uuid};
use taskchampion::{Replica, Status, Task, Uuid};
use termcolor::WriteColor;
// pending #123, this is a non-fallible way of looking up a task's working set index
@@ -125,24 +125,26 @@ fn get_report(report_name: String, filter: Filter) -> Fallible<Report> {
ascending: false,
sort_by: SortBy::Uuid,
}];
use crate::argparse::Universe;
Ok(match report_name.as_ref() {
let mut report = match report_name.as_ref() {
"list" => Report {
columns,
sort,
filter,
filter: Default::default(),
},
"next" => Report {
columns,
sort,
// TODO: merge invocation filter and report filter
filter: Filter {
universe: Universe::PendingTasks,
..Default::default()
conditions: vec![Condition::Status(Status::Pending)],
},
},
_ => bail!("Unknown report {:?}", report_name),
})
};
// intersect the report's filter with the user-supplied filter
report.filter = report.filter.intersect(filter);
Ok(report)
}
pub(super) fn display_report<W: WriteColor>(