mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
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:
parent
ad75ba49a4
commit
63e6c08fdd
10 changed files with 271 additions and 155 deletions
|
@ -32,6 +32,7 @@
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <CmdBurndown.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 |
|
// | 21 22 23 24 25 26 27 28 29 30 31 01 02 03 04 05 06 |
|
||||||
// | July August |
|
// | July August |
|
||||||
// | |
|
// | |
|
||||||
// | Find rate 1.7/d Estimated completion 8/12/2010 |
|
// | Add rate 1.7/d Estimated completion 8/12/2010 |
|
||||||
// | Fix rate 1.3/d |
|
// | Don/Delete rate 1.3/d |
|
||||||
// +---------------------------------------------------------------------+
|
// +---------------------------------------------------------------------+
|
||||||
std::string Chart::render ()
|
std::string Chart::render ()
|
||||||
{
|
{
|
||||||
|
@ -522,14 +523,14 @@ std::string Chart::render ()
|
||||||
else
|
else
|
||||||
strcpy (rate, "-");
|
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)
|
if (fix_rate != 0.0)
|
||||||
sprintf (rate, "%.1f/d", fix_rate);
|
sprintf (rate, "%.1f/d", fix_rate);
|
||||||
else
|
else
|
||||||
strcpy (rate, "-");
|
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.
|
// Draw completion date.
|
||||||
if (completion.length ())
|
if (completion.length ())
|
||||||
|
@ -982,43 +983,39 @@ int CmdBurndownMonthly::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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.
|
// Create a chart, scan the tasks, then render.
|
||||||
Chart chart ('M');
|
Chart chart ('M');
|
||||||
|
|
||||||
// Use any filter as a title.
|
// Use any filter as a title.
|
||||||
if (context.filter.size ())
|
if (context.args.size () > 2)
|
||||||
{
|
{
|
||||||
std::string combined = "(";
|
std::string combined = "("
|
||||||
|
+ context.args.extract_read_only_filter ().combine ()
|
||||||
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 += ")";
|
|
||||||
chart.description (combined);
|
chart.description (combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
chart.scan (tasks);
|
chart.scan (filtered);
|
||||||
output = chart.render ();
|
output = chart.render ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1037,43 +1034,39 @@ int CmdBurndownWeekly::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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.
|
// Create a chart, scan the tasks, then render.
|
||||||
Chart chart ('W');
|
Chart chart ('W');
|
||||||
|
|
||||||
// Use any filter as a title.
|
// Use any filter as a title.
|
||||||
if (context.filter.size ())
|
if (context.args.size () > 2)
|
||||||
{
|
{
|
||||||
std::string combined = "(";
|
std::string combined = "("
|
||||||
|
+ context.args.extract_read_only_filter ().combine ()
|
||||||
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 += ")";
|
|
||||||
chart.description (combined);
|
chart.description (combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
chart.scan (tasks);
|
chart.scan (filtered);
|
||||||
output = chart.render ();
|
output = chart.render ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1092,43 +1085,39 @@ int CmdBurndownDaily::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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.
|
// Create a chart, scan the tasks, then render.
|
||||||
Chart chart ('D');
|
Chart chart ('D');
|
||||||
|
|
||||||
// Use any filter as a title.
|
// Use any filter as a title.
|
||||||
if (context.filter.size ())
|
if (context.args.size () > 2)
|
||||||
{
|
{
|
||||||
std::string combined = "(";
|
std::string combined = "("
|
||||||
|
+ context.args.extract_read_only_filter ().combine ()
|
||||||
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 += ")";
|
|
||||||
chart.description (combined);
|
chart.description (combined);
|
||||||
}
|
}
|
||||||
|
|
||||||
chart.scan (tasks);
|
chart.scan (filtered);
|
||||||
output = chart.render ();
|
output = chart.render ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
@ -48,7 +49,7 @@ CmdHistoryMonthly::CmdHistoryMonthly ()
|
||||||
int CmdHistoryMonthly::execute (std::string& output)
|
int CmdHistoryMonthly::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
std::map <time_t, int> groups; // Represents any month with data
|
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> addedGroup; // Additions by month
|
||||||
std::map <time_t, int> completedGroup; // Completions 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;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
// Filter.
|
||||||
|
Arguments f = context.args.extract_read_only_filter ();
|
||||||
|
Expression e (f);
|
||||||
|
|
||||||
|
std::vector <Task> filtered;
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++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"));
|
Date entry (task->get ("entry"));
|
||||||
|
|
||||||
|
@ -188,7 +199,6 @@ int CmdHistoryMonthly::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,7 +216,6 @@ CmdHistoryAnnual::CmdHistoryAnnual ()
|
||||||
int CmdHistoryAnnual::execute (std::string& output)
|
int CmdHistoryAnnual::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
std::map <time_t, int> groups; // Represents any month with data
|
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> addedGroup; // Additions by month
|
||||||
std::map <time_t, int> completedGroup; // Completions 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;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
// Filter.
|
||||||
|
Arguments f = context.args.extract_read_only_filter ();
|
||||||
|
Expression e (f);
|
||||||
|
|
||||||
|
std::vector <Task> filtered;
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++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"));
|
Date entry (task->get ("entry"));
|
||||||
|
|
||||||
|
@ -343,7 +362,6 @@ int CmdHistoryAnnual::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +379,6 @@ CmdGHistoryMonthly::CmdGHistoryMonthly ()
|
||||||
int CmdGHistoryMonthly::execute (std::string& output)
|
int CmdGHistoryMonthly::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
std::map <time_t, int> groups; // Represents any month with data
|
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> addedGroup; // Additions by month
|
||||||
std::map <time_t, int> completedGroup; // Completions 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;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
// Filter.
|
||||||
|
Arguments f = context.args.extract_read_only_filter ();
|
||||||
|
Expression e (f);
|
||||||
|
|
||||||
|
std::vector <Task> filtered;
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++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"));
|
Date entry (task->get ("entry"));
|
||||||
|
|
||||||
|
@ -541,7 +568,6 @@ int CmdGHistoryMonthly::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +585,6 @@ CmdGHistoryAnnual::CmdGHistoryAnnual ()
|
||||||
int CmdGHistoryAnnual::execute (std::string& output)
|
int CmdGHistoryAnnual::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
std::map <time_t, int> groups; // Represents any month with data
|
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> addedGroup; // Additions by month
|
||||||
std::map <time_t, int> completedGroup; // Completions 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;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
|
// Filter.
|
||||||
|
Arguments f = context.args.extract_read_only_filter ();
|
||||||
|
Expression e (f);
|
||||||
|
|
||||||
|
std::vector <Task> filtered;
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++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"));
|
Date entry (task->get ("entry"));
|
||||||
|
|
||||||
|
@ -736,7 +771,6 @@ int CmdGHistoryAnnual::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
#include <CmdIDs.h>
|
#include <CmdIDs.h>
|
||||||
|
@ -47,25 +48,33 @@ CmdIDs::CmdIDs ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdIDs::execute (std::string& output)
|
int CmdIDs::execute (std::string& output)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
// Scan the pending tasks, applying any filter.
|
// Scan the pending tasks, applying any filter.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
// Find number of matching tasks.
|
// Filter.
|
||||||
std::vector <int> ids;
|
Arguments f = context.args.extract_read_only_filter ();
|
||||||
|
Expression e (f);
|
||||||
|
|
||||||
|
std::vector <Task> filtered;
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++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)
|
if (task->id)
|
||||||
ids.push_back (task->id);
|
ids.push_back (task->id);
|
||||||
|
|
||||||
std::sort (ids.begin (), ids.end ());
|
std::sort (ids.begin (), ids.end ());
|
||||||
output = compressIds (ids) + "\n";
|
output = compressIds (ids) + "\n";
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,9 +98,18 @@ int CmdCompletionIds::execute (std::string& output)
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++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 &&
|
if (task->getStatus () != Task::deleted &&
|
||||||
task->getStatus () != Task::completed)
|
task->getStatus () != Task::completed)
|
||||||
ids.push_back (task->id);
|
ids.push_back (task->id);
|
||||||
|
@ -127,9 +145,18 @@ int CmdZshCompletionIds::execute (std::string& output)
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++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 &&
|
if (task->getStatus () != Task::deleted &&
|
||||||
task->getStatus () != Task::completed)
|
task->getStatus () != Task::completed)
|
||||||
out << task->id
|
out << task->id
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
|
@ -51,17 +52,24 @@ int CmdInfo::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.loadPending (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.loadPending (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
// Filter sequence.
|
// Filter.
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
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.
|
// Read the undo file.
|
||||||
std::vector <std::string> undo;
|
std::vector <std::string> undo;
|
||||||
|
@ -74,8 +82,7 @@ int CmdInfo::execute (std::string& output)
|
||||||
|
|
||||||
// Find the task.
|
// Find the task.
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
std::vector <Task>::iterator task;
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
|
||||||
{
|
{
|
||||||
ViewText view;
|
ViewText view;
|
||||||
view.width (context.getWidth ());
|
view.width (context.getWidth ());
|
||||||
|
@ -391,14 +398,13 @@ int CmdInfo::execute (std::string& output)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! tasks.size ())
|
if (! filtered.size ())
|
||||||
{
|
{
|
||||||
out << "No matches.\n";
|
out << "No matches.\n";
|
||||||
rc = 1;
|
rc = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <CmdQuery.h>
|
#include <CmdQuery.h>
|
||||||
|
|
||||||
|
@ -46,39 +47,44 @@ int CmdQuery::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
// Filter sequence.
|
// Filter.
|
||||||
if (context.sequence.size ())
|
Arguments f = context.args.extract_read_only_filter ();
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
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.");
|
context.footnote ("No matches.");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: "limit:" feature not supported.
|
// Note: "limit:" feature not supported.
|
||||||
|
// TODO Why not?
|
||||||
|
|
||||||
// Compose output.
|
// Compose output.
|
||||||
std::vector <Task>::iterator t;
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
for (t = tasks.begin (); t != tasks.end (); ++t)
|
|
||||||
{
|
{
|
||||||
if (t != tasks.begin ())
|
if (task != filtered.begin ())
|
||||||
output += ",\n";
|
output += ",\n";
|
||||||
|
|
||||||
output += t->composeJSON (true);
|
output += task->composeJSON (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
output += "\n";
|
output += "\n";
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <util.h>
|
#include <util.h>
|
||||||
|
@ -42,7 +43,7 @@ extern Context context;
|
||||||
CmdStatistics::CmdStatistics ()
|
CmdStatistics::CmdStatistics ()
|
||||||
{
|
{
|
||||||
_keyword = "stats";
|
_keyword = "stats";
|
||||||
_usage = "task stats";
|
_usage = "task stats [<filter>]";
|
||||||
_description = "Shows task database statistics.";
|
_description = "Shows task database statistics.";
|
||||||
_read_only = true;
|
_read_only = true;
|
||||||
_displays_id = false;
|
_displays_id = false;
|
||||||
|
@ -52,7 +53,6 @@ CmdStatistics::CmdStatistics ()
|
||||||
int CmdStatistics::execute (std::string& output)
|
int CmdStatistics::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
// Go get the file sizes.
|
// Go get the file sizes.
|
||||||
|
@ -80,10 +80,21 @@ int CmdStatistics::execute (std::string& output)
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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;
|
Date now;
|
||||||
time_t earliest = time (NULL);
|
time_t earliest = time (NULL);
|
||||||
time_t latest = 1;
|
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> allTags;
|
||||||
std::map <std::string, int> allProjects;
|
std::map <std::string, int> allProjects;
|
||||||
|
|
||||||
std::vector <Task>::iterator it;
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
for (it = tasks.begin (); it != tasks.end (); ++it)
|
|
||||||
{
|
{
|
||||||
++totalT;
|
++totalT;
|
||||||
if (it->getStatus () == Task::deleted) ++deletedT;
|
if (task->getStatus () == Task::deleted) ++deletedT;
|
||||||
if (it->getStatus () == Task::pending) ++pendingT;
|
if (task->getStatus () == Task::pending) ++pendingT;
|
||||||
if (it->getStatus () == Task::completed) ++completedT;
|
if (task->getStatus () == Task::completed) ++completedT;
|
||||||
if (it->getStatus () == Task::recurring) ++recurringT;
|
if (task->getStatus () == Task::recurring) ++recurringT;
|
||||||
if (it->getStatus () == Task::waiting) ++waitingT;
|
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 < earliest) earliest = entry;
|
||||||
if (entry > latest) latest = 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;
|
daysPending += (end - entry) / 86400.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it->getStatus () == Task::pending)
|
if (task->getStatus () == Task::pending)
|
||||||
daysPending += (now.toEpoch () - entry) / 86400.0;
|
daysPending += (now.toEpoch () - entry) / 86400.0;
|
||||||
|
|
||||||
descLength += it->get ("description").length ();
|
descLength += task->get ("description").length ();
|
||||||
|
|
||||||
std::vector <Att> annotations;
|
std::vector <Att> annotations;
|
||||||
it->getAnnotations (annotations);
|
task->getAnnotations (annotations);
|
||||||
annotationsT += annotations.size ();
|
annotationsT += annotations.size ();
|
||||||
|
|
||||||
std::vector <std::string> tags;
|
std::vector <std::string> tags;
|
||||||
it->getTags (tags);
|
task->getTags (tags);
|
||||||
if (tags.size ()) ++taggedT;
|
if (tags.size ()) ++taggedT;
|
||||||
|
|
||||||
std::vector <std::string>::iterator t;
|
std::vector <std::string>::iterator t;
|
||||||
for (t = tags.begin (); t != tags.end (); ++t)
|
for (t = tags.begin (); t != tags.end (); ++t)
|
||||||
allTags[*t] = 0;
|
allTags[*t] = 0;
|
||||||
|
|
||||||
std::string project = it->get ("project");
|
std::string project = task->get ("project");
|
||||||
if (project != "")
|
if (project != "")
|
||||||
allProjects[project] = 0;
|
allProjects[project] = 0;
|
||||||
}
|
}
|
||||||
|
@ -203,7 +213,7 @@ int CmdStatistics::execute (std::string& output)
|
||||||
view.set (row, 1, value.str ());
|
view.set (row, 1, value.str ());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tasks.size ())
|
if (filtered.size ())
|
||||||
{
|
{
|
||||||
Date e (earliest);
|
Date e (earliest);
|
||||||
row = view.addRow ();
|
row = view.addRow ();
|
||||||
|
@ -274,7 +284,6 @@ int CmdStatistics::execute (std::string& output)
|
||||||
<< optionalBlankLine ();
|
<< optionalBlankLine ();
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,7 @@
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <CmdSummary.h>
|
#include <CmdSummary.h>
|
||||||
|
@ -54,19 +55,28 @@ int CmdSummary::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
// Scan the pending tasks.
|
// Scan the pending tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
context.tdb.unlock ();
|
||||||
|
|
||||||
// Generate unique list of project names from all pending tasks.
|
// Filter.
|
||||||
std::map <std::string, bool> allProjects;
|
Arguments f = context.args.extract_read_only_filter ();
|
||||||
|
Expression e (f);
|
||||||
|
|
||||||
|
std::vector <Task> filtered;
|
||||||
std::vector <Task>::iterator task;
|
std::vector <Task>::iterator task;
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++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)
|
if (task->getStatus () == Task::pending)
|
||||||
allProjects[task->get ("project")] = false;
|
allProjects[task->get ("project")] = false;
|
||||||
|
|
||||||
|
@ -88,7 +98,7 @@ int CmdSummary::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the various tasks.
|
// 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");
|
std::string project = task->get ("project");
|
||||||
++counter[project];
|
++counter[project];
|
||||||
|
@ -176,7 +186,6 @@ int CmdSummary::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <CmdTags.h>
|
#include <CmdTags.h>
|
||||||
#include <text.h>
|
#include <text.h>
|
||||||
|
@ -49,28 +50,37 @@ CmdTags::CmdTags ()
|
||||||
int CmdTags::execute (std::string& output)
|
int CmdTags::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
/*
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
int quantity = 0;
|
int quantity = 0;
|
||||||
|
Filter filter;
|
||||||
if (context.config.getBoolean ("list.all.tags"))
|
if (context.config.getBoolean ("list.all.tags"))
|
||||||
quantity += context.tdb.load (tasks, context.filter);
|
quantity += context.tdb.load (tasks, filter);
|
||||||
else
|
else
|
||||||
quantity += context.tdb.loadPending (tasks, context.filter);
|
quantity += context.tdb.loadPending (tasks, filter);
|
||||||
|
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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
|
// Scan all the tasks for their project name, building a map using project
|
||||||
// names as keys.
|
// names as keys.
|
||||||
std::map <std::string, int> unique;
|
std::map <std::string, int> unique;
|
||||||
std::vector <Task>::iterator t;
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
for (t = tasks.begin (); t != tasks.end (); ++t)
|
|
||||||
{
|
{
|
||||||
std::vector <std::string> tags;
|
std::vector <std::string> tags;
|
||||||
t->getTags (tags);
|
task->getTags (tags);
|
||||||
|
|
||||||
std::vector <std::string>::iterator tag;
|
std::vector <std::string>::iterator tag;
|
||||||
for (tag = tags.begin (); tag != tags.end (); ++tag)
|
for (tag = tags.begin (); tag != tags.end (); ++tag)
|
||||||
|
@ -118,7 +128,6 @@ int CmdTags::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +144,6 @@ CmdCompletionTags::CmdCompletionTags ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdCompletionTags::execute (std::string& output)
|
int CmdCompletionTags::execute (std::string& output)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
|
|
||||||
|
@ -148,11 +156,20 @@ int CmdCompletionTags::execute (std::string& output)
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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
|
// Scan all the tasks for their tags, building a map using tag
|
||||||
// names as keys.
|
// names as keys.
|
||||||
std::map <std::string, int> unique;
|
std::map <std::string, int> unique;
|
||||||
std::vector <Task>::iterator task;
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
|
||||||
{
|
{
|
||||||
std::vector <std::string> tags;
|
std::vector <std::string> tags;
|
||||||
task->getTags (tags);
|
task->getTags (tags);
|
||||||
|
@ -176,7 +193,6 @@ int CmdCompletionTags::execute (std::string& output)
|
||||||
out << it->first << "\n";
|
out << it->first << "\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <ViewText.h>
|
#include <ViewText.h>
|
||||||
#include <Date.h>
|
#include <Date.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
@ -50,15 +51,25 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
|
|
||||||
/*
|
|
||||||
// Scan the pending tasks.
|
// Scan the pending tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.load (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.load (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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.
|
// Just do this once.
|
||||||
int width = context.getWidth ();
|
int width = context.getWidth ();
|
||||||
|
|
||||||
|
@ -79,8 +90,11 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
|
|
||||||
// Determine how many reports to run.
|
// Determine how many reports to run.
|
||||||
int quantity = 1;
|
int quantity = 1;
|
||||||
|
/*
|
||||||
|
TODO Need some command line parsing.
|
||||||
if (context.sequence.size () == 1)
|
if (context.sequence.size () == 1)
|
||||||
quantity = context.sequence[0];
|
quantity = context.sequence[0];
|
||||||
|
*/
|
||||||
|
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
for (int week = 0; week < quantity; ++week)
|
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.right", "Due"));
|
||||||
completed.add (Column::factory ("string", "Description"));
|
completed.add (Column::factory ("string", "Description"));
|
||||||
|
|
||||||
std::vector <Task>::iterator task;
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
|
||||||
{
|
{
|
||||||
// If task completed within range.
|
// If task completed within range.
|
||||||
if (task->getStatus () == Task::completed)
|
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.right", "Due"));
|
||||||
started.add (Column::factory ("string", "Description"));
|
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 started within range, but not completed withing range.
|
||||||
if (task->getStatus () == Task::pending &&
|
if (task->getStatus () == Task::pending &&
|
||||||
|
@ -180,7 +193,6 @@ int CmdTimesheet::execute (std::string& output)
|
||||||
}
|
}
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
#include <Expression.h>
|
||||||
#include <main.h>
|
#include <main.h>
|
||||||
#include <CmdUrgency.h>
|
#include <CmdUrgency.h>
|
||||||
|
|
||||||
|
@ -46,18 +47,27 @@ CmdUrgency::CmdUrgency ()
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdUrgency::execute (std::string& output)
|
int CmdUrgency::execute (std::string& output)
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
// Get all the tasks.
|
// Get all the tasks.
|
||||||
std::vector <Task> tasks;
|
std::vector <Task> tasks;
|
||||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||||
handleRecurrence ();
|
handleRecurrence ();
|
||||||
context.tdb.loadPending (tasks, context.filter);
|
Filter filter;
|
||||||
|
context.tdb.loadPending (tasks, filter);
|
||||||
context.tdb.commit ();
|
context.tdb.commit ();
|
||||||
context.tdb.unlock ();
|
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.
|
// Filter sequence.
|
||||||
context.filter.applySequence (tasks, context.sequence);
|
if (filtered.size () == 0)
|
||||||
if (tasks.size () == 0)
|
|
||||||
{
|
{
|
||||||
context.footnote ("No tasks specified.");
|
context.footnote ("No tasks specified.");
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -65,8 +75,7 @@ int CmdUrgency::execute (std::string& output)
|
||||||
|
|
||||||
// Find the task(s).
|
// Find the task(s).
|
||||||
std::stringstream out;
|
std::stringstream out;
|
||||||
std::vector <Task>::iterator task;
|
for (task = filtered.begin (); task != filtered.end (); ++task)
|
||||||
for (task = tasks.begin (); task != tasks.end (); ++task)
|
|
||||||
out << "task "
|
out << "task "
|
||||||
<< task->id
|
<< task->id
|
||||||
<< " urgency "
|
<< " urgency "
|
||||||
|
@ -74,7 +83,6 @@ int CmdUrgency::execute (std::string& output)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
|
|
||||||
output = out.str ();
|
output = out.str ();
|
||||||
*/
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue