mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-04 10:37:19 +02:00
Filter
- Fixed ::pendingOnly, which now has a clearly-defined set of rules.
This commit is contained in:
parent
da95c16da9
commit
688dcb6cd3
1 changed files with 27 additions and 30 deletions
|
@ -208,44 +208,41 @@ bool Filter::pendingOnly ()
|
||||||
{
|
{
|
||||||
Tree* tree = context.parser.tree ();
|
Tree* tree = context.parser.tree ();
|
||||||
|
|
||||||
// If the filter starts with "status:pending", the completed.data does not
|
// To skip loading completed.data, there should be:
|
||||||
// need to be accessed..
|
// - 'status:pending'
|
||||||
if (tree->_branches.size () > 0 &&
|
// - no 'or' operators
|
||||||
tree->_branches[0]->attribute ("name") == "status" &&
|
// - no 'xor' operators
|
||||||
tree->_branches[0]->attribute ("value") == "pending")
|
int countStatus = 0;
|
||||||
{
|
int countPending = 0;
|
||||||
context.debug ("Filter::pendingOnly - skipping completed.data (status:pending first)");
|
int countId = 0;
|
||||||
return true;
|
int countOr = 0;
|
||||||
}
|
int countXor = 0;
|
||||||
|
|
||||||
// Shortcut: If the filter contains no 'or' or 'xor' operators, IDs and no UUIDs.
|
|
||||||
int countId = 0;
|
|
||||||
int countUUID = 0;
|
|
||||||
int countOr = 0;
|
|
||||||
int countXor = 0;
|
|
||||||
|
|
||||||
std::vector <Tree*>::iterator i;
|
std::vector <Tree*>::iterator i;
|
||||||
for (i = tree->_branches.begin (); i != tree->_branches.end (); ++i)
|
for (i = tree->_branches.begin (); i != tree->_branches.end (); ++i)
|
||||||
{
|
{
|
||||||
if ((*i)->hasTag ("OP"))
|
if ((*i)->hasTag ("FILTER"))
|
||||||
{
|
{
|
||||||
if ((*i)->attribute ("canonical") == "or") ++countOr;
|
if ((*i)->hasTag ("ID")) ++countId;
|
||||||
if ((*i)->attribute ("canonical") == "xor") ++countXor;
|
if ((*i)->hasTag ("OP") && (*i)->attribute ("raw") == "or") ++countOr;
|
||||||
|
if ((*i)->hasTag ("OP") && (*i)->attribute ("raw") == "xor") ++countXor;
|
||||||
|
if ((*i)->hasTag ("ATTRIBUTE") && (*i)->attribute ("name") == "status") ++countStatus;
|
||||||
|
if ((*i)->hasTag ("ATTRIBUTE") && (*i)->attribute ("raw") == "pending") ++countPending;
|
||||||
}
|
}
|
||||||
else if ((*i)->hasTag ("ID")) ++countId;
|
|
||||||
else if ((*i)->hasTag ("UUID")) ++countUUID;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (countOr == 0 &&
|
// Use of 'or' or 'xor' means the potential for alternation.
|
||||||
countXor == 0 &&
|
if (countOr || countXor)
|
||||||
countUUID == 0 &&
|
return false;
|
||||||
countId > 0)
|
|
||||||
{
|
|
||||||
context.debug ("Filter::pendingOnly - skipping completed.data (IDs, no OR, no XOR, no UUID)");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
// If the filter does not contain id or status terms, read both files.
|
||||||
|
if (countId == 0 && countStatus == 0)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Only one 'status == pending' is allowed.
|
||||||
|
if (countStatus == 1 && countPending != 1)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue