Expressions

- Re-enabled read-only commands that were broken because expressions
  were not implemented.  Currently they don't work, but the mechanism
  is in place.
This commit is contained in:
Paul Beckingham 2011-06-11 14:30:19 -04:00
parent ad75ba49a4
commit 63e6c08fdd
10 changed files with 271 additions and 155 deletions

View file

@ -32,6 +32,7 @@
#include <Context.h>
#include <Date.h>
#include <Duration.h>
#include <Expression.h>
#include <main.h>
#include <CmdBurndown.h>
@ -392,8 +393,8 @@ void Chart::scan (std::vector <Task>& tasks)
// | 21 22 23 24 25 26 27 28 29 30 31 01 02 03 04 05 06 |
// | July August |
// | |
// | Find rate 1.7/d Estimated completion 8/12/2010 |
// | Fix rate 1.3/d |
// | Add rate 1.7/d Estimated completion 8/12/2010 |
// | Don/Delete rate 1.3/d |
// +---------------------------------------------------------------------+
std::string Chart::render ()
{
@ -522,14 +523,14 @@ std::string Chart::render ()
else
strcpy (rate, "-");
grid.replace (LOC (height - 2, max_label + 3), 11 + strlen (rate), std::string ("Find rate: ") + rate);
grid.replace (LOC (height - 2, max_label + 3), 11 + strlen (rate), std::string ("Add rate: ") + rate);
if (fix_rate != 0.0)
sprintf (rate, "%.1f/d", fix_rate);
else
strcpy (rate, "-");
grid.replace (LOC (height - 1, max_label + 3), 11 + strlen (rate), std::string ("Fix rate: ") + rate);
grid.replace (LOC (height - 1, max_label + 3), 11 + strlen (rate), std::string ("Done/Delete rate: ") + rate);
// Draw completion date.
if (completion.length ())
@ -982,43 +983,39 @@ int CmdBurndownMonthly::execute (std::string& output)
{
int rc = 0;
/*
// Scan the pending tasks, applying any filter.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Create a chart, scan the tasks, then render.
Chart chart ('M');
// Use any filter as a title.
if (context.filter.size ())
if (context.args.size () > 2)
{
std::string combined = "(";
for (unsigned int i = 0; i < context.filter.size (); ++i)
{
if (i)
combined += " ";
combined += context.filter[i].name ();
if (context.filter[i].mod ().length ())
combined += "." + context.filter[i].mod ();
combined += ":" + context.filter[i].value ();
}
combined += ")";
std::string combined = "("
+ context.args.extract_read_only_filter ().combine ()
+ ")";
chart.description (combined);
}
chart.scan (tasks);
chart.scan (filtered);
output = chart.render ();
*/
return rc;
}
@ -1037,43 +1034,39 @@ int CmdBurndownWeekly::execute (std::string& output)
{
int rc = 0;
/*
// Scan the pending tasks, applying any filter.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Create a chart, scan the tasks, then render.
Chart chart ('W');
// Use any filter as a title.
if (context.filter.size ())
if (context.args.size () > 2)
{
std::string combined = "(";
for (unsigned int i = 0; i < context.filter.size (); ++i)
{
if (i)
combined += " ";
combined += context.filter[i].name ();
if (context.filter[i].mod ().length ())
combined += "." + context.filter[i].mod ();
combined += ":" + context.filter[i].value ();
}
combined += ")";
std::string combined = "("
+ context.args.extract_read_only_filter ().combine ()
+ ")";
chart.description (combined);
}
chart.scan (tasks);
chart.scan (filtered);
output = chart.render ();
*/
return rc;
}
@ -1092,43 +1085,39 @@ int CmdBurndownDaily::execute (std::string& output)
{
int rc = 0;
/*
// Scan the pending tasks, applying any filter.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Create a chart, scan the tasks, then render.
Chart chart ('D');
// Use any filter as a title.
if (context.filter.size ())
if (context.args.size () > 2)
{
std::string combined = "(";
for (unsigned int i = 0; i < context.filter.size (); ++i)
{
if (i)
combined += " ";
combined += context.filter[i].name ();
if (context.filter[i].mod ().length ())
combined += "." + context.filter[i].mod ();
combined += ":" + context.filter[i].value ();
}
combined += ")";
std::string combined = "("
+ context.args.extract_read_only_filter ().combine ()
+ ")";
chart.description (combined);
}
chart.scan (tasks);
chart.scan (filtered);
output = chart.render ();
*/
return rc;
}

View file

@ -27,6 +27,7 @@
#include <sstream>
#include <Context.h>
#include <Expression.h>
#include <ViewText.h>
#include <main.h>
#include <text.h>
@ -48,7 +49,7 @@ CmdHistoryMonthly::CmdHistoryMonthly ()
int CmdHistoryMonthly::execute (std::string& output)
{
int rc = 0;
/*
std::map <time_t, int> groups; // Represents any month with data
std::map <time_t, int> addedGroup; // Additions by month
std::map <time_t, int> completedGroup; // Completions by month
@ -58,12 +59,22 @@ int CmdHistoryMonthly::execute (std::string& output)
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
for (task = filtered.begin (); task != filtered.end (); ++task)
{
Date entry (task->get ("entry"));
@ -188,7 +199,6 @@ int CmdHistoryMonthly::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}
@ -206,7 +216,6 @@ CmdHistoryAnnual::CmdHistoryAnnual ()
int CmdHistoryAnnual::execute (std::string& output)
{
int rc = 0;
/*
std::map <time_t, int> groups; // Represents any month with data
std::map <time_t, int> addedGroup; // Additions by month
std::map <time_t, int> completedGroup; // Completions by month
@ -216,12 +225,22 @@ int CmdHistoryAnnual::execute (std::string& output)
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
for (task = filtered.begin (); task != filtered.end (); ++task)
{
Date entry (task->get ("entry"));
@ -343,7 +362,6 @@ int CmdHistoryAnnual::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}
@ -361,7 +379,6 @@ CmdGHistoryMonthly::CmdGHistoryMonthly ()
int CmdGHistoryMonthly::execute (std::string& output)
{
int rc = 0;
/*
std::map <time_t, int> groups; // Represents any month with data
std::map <time_t, int> addedGroup; // Additions by month
std::map <time_t, int> completedGroup; // Completions by month
@ -371,12 +388,22 @@ int CmdGHistoryMonthly::execute (std::string& output)
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
for (task = filtered.begin (); task != filtered.end (); ++task)
{
Date entry (task->get ("entry"));
@ -541,7 +568,6 @@ int CmdGHistoryMonthly::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}
@ -559,7 +585,6 @@ CmdGHistoryAnnual::CmdGHistoryAnnual ()
int CmdGHistoryAnnual::execute (std::string& output)
{
int rc = 0;
/*
std::map <time_t, int> groups; // Represents any month with data
std::map <time_t, int> addedGroup; // Additions by month
std::map <time_t, int> completedGroup; // Completions by month
@ -569,12 +594,22 @@ int CmdGHistoryAnnual::execute (std::string& output)
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
for (task = filtered.begin (); task != filtered.end (); ++task)
{
Date entry (task->get ("entry"));
@ -736,7 +771,6 @@ int CmdGHistoryAnnual::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}

View file

@ -28,6 +28,7 @@
#include <sstream>
#include <algorithm>
#include <Context.h>
#include <Expression.h>
#include <main.h>
#include <util.h>
#include <CmdIDs.h>
@ -47,25 +48,33 @@ CmdIDs::CmdIDs ()
////////////////////////////////////////////////////////////////////////////////
int CmdIDs::execute (std::string& output)
{
/*
// Scan the pending tasks, applying any filter.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Find number of matching tasks.
std::vector <int> ids;
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Find number of matching tasks.
std::vector <int> ids;
for (task = filtered.begin (); task != filtered.end (); ++task)
if (task->id)
ids.push_back (task->id);
std::sort (ids.begin (), ids.end ());
output = compressIds (ids) + "\n";
*/
return 0;
}
@ -89,9 +98,18 @@ int CmdCompletionIds::execute (std::string& output)
context.tdb.commit ();
context.tdb.unlock ();
std::vector <int> ids;
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
std::vector <int> ids;
for (task = filtered.begin (); task != filtered.end (); ++task)
if (task->getStatus () != Task::deleted &&
task->getStatus () != Task::completed)
ids.push_back (task->id);
@ -127,9 +145,18 @@ int CmdZshCompletionIds::execute (std::string& output)
context.tdb.commit ();
context.tdb.unlock ();
std::stringstream out;
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
std::stringstream out;
for (task = filtered.begin (); task != filtered.end (); ++task)
if (task->getStatus () != Task::deleted &&
task->getStatus () != Task::completed)
out << task->id

View file

@ -28,6 +28,7 @@
#include <sstream>
#include <stdlib.h>
#include <Context.h>
#include <Expression.h>
#include <Date.h>
#include <Duration.h>
#include <ViewText.h>
@ -51,17 +52,24 @@ int CmdInfo::execute (std::string& output)
{
int rc = 0;
/*
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.loadPending (tasks, context.filter);
Filter filter;
context.tdb.loadPending (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter sequence.
context.filter.applySequence (tasks, context.sequence);
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Read the undo file.
std::vector <std::string> undo;
@ -74,8 +82,7 @@ int CmdInfo::execute (std::string& output)
// Find the task.
std::stringstream out;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
ViewText view;
view.width (context.getWidth ());
@ -391,14 +398,13 @@ int CmdInfo::execute (std::string& output)
<< "\n";
}
if (! tasks.size ())
if (! filtered.size ())
{
out << "No matches.\n";
rc = 1;
}
output = out.str ();
*/
return rc;
}

View file

@ -26,6 +26,7 @@
////////////////////////////////////////////////////////////////////////////////
#include <Context.h>
#include <Expression.h>
#include <main.h>
#include <CmdQuery.h>
@ -46,39 +47,44 @@ int CmdQuery::execute (std::string& output)
{
int rc = 0;
/*
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter sequence.
if (context.sequence.size ())
context.filter.applySequence (tasks, context.sequence);
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
if (tasks.size () == 0)
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
if (filtered.size () == 0)
{
context.footnote ("No matches.");
return 1;
}
// Note: "limit:" feature not supported.
// TODO Why not?
// Compose output.
std::vector <Task>::iterator t;
for (t = tasks.begin (); t != tasks.end (); ++t)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
if (t != tasks.begin ())
if (task != filtered.begin ())
output += ",\n";
output += t->composeJSON (true);
output += task->composeJSON (true);
}
output += "\n";
*/
return rc;
}

View file

@ -31,6 +31,7 @@
#include <ViewText.h>
#include <Duration.h>
#include <Context.h>
#include <Expression.h>
#include <main.h>
#include <text.h>
#include <util.h>
@ -42,7 +43,7 @@ extern Context context;
CmdStatistics::CmdStatistics ()
{
_keyword = "stats";
_usage = "task stats";
_usage = "task stats [<filter>]";
_description = "Shows task database statistics.";
_read_only = true;
_displays_id = false;
@ -52,7 +53,6 @@ CmdStatistics::CmdStatistics ()
int CmdStatistics::execute (std::string& output)
{
int rc = 0;
/*
std::stringstream out;
// Go get the file sizes.
@ -80,10 +80,21 @@ int CmdStatistics::execute (std::string& output)
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
Date now;
time_t earliest = time (NULL);
time_t latest = 1;
@ -100,44 +111,43 @@ int CmdStatistics::execute (std::string& output)
std::map <std::string, int> allTags;
std::map <std::string, int> allProjects;
std::vector <Task>::iterator it;
for (it = tasks.begin (); it != tasks.end (); ++it)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
++totalT;
if (it->getStatus () == Task::deleted) ++deletedT;
if (it->getStatus () == Task::pending) ++pendingT;
if (it->getStatus () == Task::completed) ++completedT;
if (it->getStatus () == Task::recurring) ++recurringT;
if (it->getStatus () == Task::waiting) ++waitingT;
if (task->getStatus () == Task::deleted) ++deletedT;
if (task->getStatus () == Task::pending) ++pendingT;
if (task->getStatus () == Task::completed) ++completedT;
if (task->getStatus () == Task::recurring) ++recurringT;
if (task->getStatus () == Task::waiting) ++waitingT;
time_t entry = strtol (it->get ("entry").c_str (), NULL, 10);
time_t entry = strtol (task->get ("entry").c_str (), NULL, 10);
if (entry < earliest) earliest = entry;
if (entry > latest) latest = entry;
if (it->getStatus () == Task::completed)
if (task->getStatus () == Task::completed)
{
time_t end = strtol (it->get ("end").c_str (), NULL, 10);
time_t end = strtol (task->get ("end").c_str (), NULL, 10);
daysPending += (end - entry) / 86400.0;
}
if (it->getStatus () == Task::pending)
if (task->getStatus () == Task::pending)
daysPending += (now.toEpoch () - entry) / 86400.0;
descLength += it->get ("description").length ();
descLength += task->get ("description").length ();
std::vector <Att> annotations;
it->getAnnotations (annotations);
task->getAnnotations (annotations);
annotationsT += annotations.size ();
std::vector <std::string> tags;
it->getTags (tags);
task->getTags (tags);
if (tags.size ()) ++taggedT;
std::vector <std::string>::iterator t;
for (t = tags.begin (); t != tags.end (); ++t)
allTags[*t] = 0;
std::string project = it->get ("project");
std::string project = task->get ("project");
if (project != "")
allProjects[project] = 0;
}
@ -203,7 +213,7 @@ int CmdStatistics::execute (std::string& output)
view.set (row, 1, value.str ());
}
if (tasks.size ())
if (filtered.size ())
{
Date e (earliest);
row = view.addRow ();
@ -274,7 +284,6 @@ int CmdStatistics::execute (std::string& output)
<< optionalBlankLine ();
output = out.str ();
*/
return rc;
}

View file

@ -30,6 +30,7 @@
#include <Context.h>
#include <ViewText.h>
#include <Duration.h>
#include <Expression.h>
#include <text.h>
#include <main.h>
#include <CmdSummary.h>
@ -54,19 +55,28 @@ int CmdSummary::execute (std::string& output)
{
int rc = 0;
/*
// Scan the pending tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Generate unique list of project names from all pending tasks.
std::map <std::string, bool> allProjects;
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Generate unique list of project names from all pending tasks.
std::map <std::string, bool> allProjects;
for (task = filtered.begin (); task != filtered.end (); ++task)
if (task->getStatus () == Task::pending)
allProjects[task->get ("project")] = false;
@ -88,7 +98,7 @@ int CmdSummary::execute (std::string& output)
}
// Count the various tasks.
for (task = tasks.begin (); task != tasks.end (); ++task)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
std::string project = task->get ("project");
++counter[project];
@ -176,7 +186,6 @@ int CmdSummary::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}

View file

@ -29,6 +29,7 @@
#include <vector>
#include <stdlib.h>
#include <Context.h>
#include <Expression.h>
#include <ViewText.h>
#include <CmdTags.h>
#include <text.h>
@ -49,28 +50,37 @@ CmdTags::CmdTags ()
int CmdTags::execute (std::string& output)
{
int rc = 0;
/*
std::stringstream out;
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
int quantity = 0;
Filter filter;
if (context.config.getBoolean ("list.all.tags"))
quantity += context.tdb.load (tasks, context.filter);
quantity += context.tdb.load (tasks, filter);
else
quantity += context.tdb.loadPending (tasks, context.filter);
quantity += context.tdb.loadPending (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Scan all the tasks for their project name, building a map using project
// names as keys.
std::map <std::string, int> unique;
std::vector <Task>::iterator t;
for (t = tasks.begin (); t != tasks.end (); ++t)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
std::vector <std::string> tags;
t->getTags (tags);
task->getTags (tags);
std::vector <std::string>::iterator tag;
for (tag = tags.begin (); tag != tags.end (); ++tag)
@ -118,7 +128,6 @@ int CmdTags::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}
@ -135,7 +144,6 @@ CmdCompletionTags::CmdCompletionTags ()
////////////////////////////////////////////////////////////////////////////////
int CmdCompletionTags::execute (std::string& output)
{
/*
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
@ -148,11 +156,20 @@ int CmdCompletionTags::execute (std::string& output)
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Scan all the tasks for their tags, building a map using tag
// names as keys.
std::map <std::string, int> unique;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
std::vector <std::string> tags;
task->getTags (tags);
@ -176,7 +193,6 @@ int CmdCompletionTags::execute (std::string& output)
out << it->first << "\n";
output = out.str ();
*/
return 0;
}

View file

@ -28,6 +28,7 @@
#include <sstream>
#include <stdlib.h>
#include <Context.h>
#include <Expression.h>
#include <ViewText.h>
#include <Date.h>
#include <main.h>
@ -50,15 +51,25 @@ int CmdTimesheet::execute (std::string& output)
{
int rc = 0;
/*
// Scan the pending tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
Filter filter;
context.tdb.load (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Just do this once.
int width = context.getWidth ();
@ -79,8 +90,11 @@ int CmdTimesheet::execute (std::string& output)
// Determine how many reports to run.
int quantity = 1;
/*
TODO Need some command line parsing.
if (context.sequence.size () == 1)
quantity = context.sequence[0];
*/
std::stringstream out;
for (int week = 0; week < quantity; ++week)
@ -105,8 +119,7 @@ int CmdTimesheet::execute (std::string& output)
completed.add (Column::factory ("string.right", "Due"));
completed.add (Column::factory ("string", "Description"));
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
// If task completed within range.
if (task->getStatus () == Task::completed)
@ -143,7 +156,7 @@ int CmdTimesheet::execute (std::string& output)
started.add (Column::factory ("string.right", "Due"));
started.add (Column::factory ("string", "Description"));
for (task = tasks.begin (); task != tasks.end (); ++task)
for (task = filtered.begin (); task != filtered.end (); ++task)
{
// If task started within range, but not completed withing range.
if (task->getStatus () == Task::pending &&
@ -180,7 +193,6 @@ int CmdTimesheet::execute (std::string& output)
}
output = out.str ();
*/
return rc;
}

View file

@ -28,6 +28,7 @@
#include <sstream>
#include <stdlib.h>
#include <Context.h>
#include <Expression.h>
#include <main.h>
#include <CmdUrgency.h>
@ -46,18 +47,27 @@ CmdUrgency::CmdUrgency ()
////////////////////////////////////////////////////////////////////////////////
int CmdUrgency::execute (std::string& output)
{
/*
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.loadPending (tasks, context.filter);
Filter filter;
context.tdb.loadPending (tasks, filter);
context.tdb.commit ();
context.tdb.unlock ();
// Filter.
Arguments f = context.args.extract_read_only_filter ();
Expression e (f);
std::vector <Task> filtered;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
if (e.eval (*task))
filtered.push_back (*task);
// Filter sequence.
context.filter.applySequence (tasks, context.sequence);
if (tasks.size () == 0)
if (filtered.size () == 0)
{
context.footnote ("No tasks specified.");
return 1;
@ -65,8 +75,7 @@ int CmdUrgency::execute (std::string& output)
// Find the task(s).
std::stringstream out;
std::vector <Task>::iterator task;
for (task = tasks.begin (); task != tasks.end (); ++task)
for (task = filtered.begin (); task != filtered.end (); ++task)
out << "task "
<< task->id
<< " urgency "
@ -74,7 +83,6 @@ int CmdUrgency::execute (std::string& output)
<< "\n";
output = out.str ();
*/
return 0;
}