- Fixed bug that caused an unexpected number of tasks to be displayed
  by the next command.
This commit is contained in:
Paul Beckingham 2009-07-09 23:07:50 -04:00
parent f790d52f62
commit 4439c07516

View file

@ -1836,13 +1836,11 @@ void gatherNextTasks (std::vector <Task>& tasks)
std::vector <Task> filtered; std::vector <Task> filtered;
Date now; Date now;
// How many items per project? Default 3. // How many items per project? Default 2.
int limit = context.config.get ("next", 3); int limit = context.config.get ("next", 2);
// due:< 1wk, pri:* // due:< 1wk, pri:*
foreach (task, tasks) foreach (task, tasks)
{
if (task->getStatus () == Task::pending)
{ {
if (task->has ("due")) if (task->has ("due"))
{ {
@ -1859,12 +1857,9 @@ void gatherNextTasks (std::vector <Task>& tasks)
} }
} }
} }
}
// due:*, pri:H // due:*, pri:H
foreach (task, tasks) foreach (task, tasks)
{
if (task->getStatus () == Task::pending)
{ {
if (task->has ("due")) if (task->has ("due"))
{ {
@ -1881,12 +1876,9 @@ void gatherNextTasks (std::vector <Task>& tasks)
} }
} }
} }
}
// pri:H // pri:H
foreach (task, tasks) foreach (task, tasks)
{
if (task->getStatus () == Task::pending)
{ {
std::string priority = task->get ("priority"); std::string priority = task->get ("priority");
if (priority == "H") if (priority == "H")
@ -1900,12 +1892,9 @@ void gatherNextTasks (std::vector <Task>& tasks)
} }
} }
} }
}
// due:*, pri:M // due:*, pri:M
foreach (task, tasks) foreach (task, tasks)
{
if (task->getStatus () == Task::pending)
{ {
if (task->has ("due")) if (task->has ("due"))
{ {
@ -1922,12 +1911,9 @@ void gatherNextTasks (std::vector <Task>& tasks)
} }
} }
} }
}
// pri:M // pri:M
foreach (task, tasks) foreach (task, tasks)
{
if (task->getStatus () == Task::pending)
{ {
std::string priority = task->get ("priority"); std::string priority = task->get ("priority");
if (priority == "M") if (priority == "M")
@ -1941,12 +1927,9 @@ void gatherNextTasks (std::vector <Task>& tasks)
} }
} }
} }
}
// due:*, pri:L // due:*, pri:L
foreach (task, tasks) foreach (task, tasks)
{
if (task->getStatus () == Task::pending)
{ {
if (task->has ("due")) if (task->has ("due"))
{ {
@ -1963,12 +1946,9 @@ void gatherNextTasks (std::vector <Task>& tasks)
} }
} }
} }
}
// pri:L // pri:L
foreach (task, tasks) foreach (task, tasks)
{
if (task->getStatus () == Task::pending)
{ {
std::string priority = task->get ("priority"); std::string priority = task->get ("priority");
if (priority == "L") if (priority == "L")
@ -1982,12 +1962,9 @@ void gatherNextTasks (std::vector <Task>& tasks)
} }
} }
} }
}
// due:, pri: // due:, pri:
foreach (task, tasks) foreach (task, tasks)
{
if (task->getStatus () == Task::pending)
{ {
if (task->has ("due")) if (task->has ("due"))
{ {
@ -2004,6 +1981,17 @@ void gatherNextTasks (std::vector <Task>& tasks)
} }
} }
} }
// Filler.
foreach (task, tasks)
{
std::string project = task->get ("project");
if (countByProject[project] < limit && matching.find (task->id) == matching.end ())
{
++countByProject[project];
matching[task->id] = true;
filtered.push_back (*task);
}
} }
tasks = filtered; tasks = filtered;