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:
@@ -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>(
|
||||
|
||||
Reference in New Issue
Block a user