TDB2 Conversion
- Migrated several commands over to use TDB2. Have to start somewhere.
This commit is contained in:
@@ -48,17 +48,9 @@ CmdCount::CmdCount ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdCount::execute (std::string& output)
|
||||
{
|
||||
// Get all the tasks.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
handleRecurrence ();
|
||||
context.tdb.load (tasks);
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
// Apply filter.
|
||||
std::vector <Task> filtered;
|
||||
filter (tasks, filtered);
|
||||
filter (filtered);
|
||||
|
||||
// Find number of matching tasks. Skip recurring parent tasks.
|
||||
int count = 0;
|
||||
|
||||
@@ -93,7 +93,6 @@ int CmdCustom::execute (std::string& output)
|
||||
|
||||
// Load the data.
|
||||
handleRecurrence ();
|
||||
context.tdb2.commit ();
|
||||
std::vector <Task> filtered;
|
||||
filter (filtered);
|
||||
|
||||
@@ -177,6 +176,8 @@ int CmdCustom::execute (std::string& output)
|
||||
rc = 1;
|
||||
}
|
||||
|
||||
context.tdb2.commit ();
|
||||
|
||||
output = out.str ();
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -50,17 +50,11 @@ 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.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
// Apply filter.
|
||||
handleRecurrence ();
|
||||
std::vector <Task> filtered;
|
||||
filter (tasks, filtered);
|
||||
filter (filtered);
|
||||
context.tdb.commit ();
|
||||
|
||||
// Find number of matching tasks.
|
||||
std::vector <int> ids;
|
||||
@@ -87,15 +81,11 @@ CmdCompletionIds::CmdCompletionIds ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdCompletionIds::execute (std::string& output)
|
||||
{
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
context.tdb.loadPending (tasks);
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
// Apply filter.
|
||||
handleRecurrence ();
|
||||
std::vector <Task> filtered;
|
||||
filter (tasks, filtered);
|
||||
filter (filtered);
|
||||
context.tdb.commit ();
|
||||
|
||||
std::vector <int> ids;
|
||||
std::vector <Task>::iterator task;
|
||||
@@ -128,15 +118,11 @@ CmdZshCompletionIds::CmdZshCompletionIds ()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int CmdZshCompletionIds::execute (std::string& output)
|
||||
{
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
context.tdb.loadPending (tasks);
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
// Apply filter.
|
||||
handleRecurrence ();
|
||||
std::vector <Task> filtered;
|
||||
filter (tasks, filtered);
|
||||
filter (filtered);
|
||||
context.tdb.commit ();
|
||||
|
||||
std::stringstream out;
|
||||
std::vector <Task>::iterator task;
|
||||
|
||||
@@ -81,16 +81,9 @@ int CmdStatistics::execute (std::string& output)
|
||||
++undoCount;
|
||||
|
||||
// Get all the tasks.
|
||||
std::vector <Task> tasks;
|
||||
context.tdb.lock (context.config.getBoolean ("locking"));
|
||||
handleRecurrence ();
|
||||
context.tdb.load (tasks);
|
||||
context.tdb.commit ();
|
||||
context.tdb.unlock ();
|
||||
|
||||
// Apply filter.
|
||||
std::vector <Task> filtered;
|
||||
filter (tasks, filtered);
|
||||
filter (context.tdb2.pending.get_tasks (), filtered);
|
||||
filter (context.tdb2.completed.get_tasks (), filtered);
|
||||
|
||||
Date now;
|
||||
time_t earliest = time (NULL);
|
||||
|
||||
@@ -267,7 +267,7 @@ bool Command::displays_id () const
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Filter a specific list of tasks.
|
||||
void Command::filter (std::vector <Task>& input, std::vector <Task>& output)
|
||||
void Command::filter (const std::vector <Task>& input, std::vector <Task>& output)
|
||||
{
|
||||
context.timer_filter.start ();
|
||||
|
||||
@@ -278,7 +278,7 @@ void Command::filter (std::vector <Task>& input, std::vector <Task>& output)
|
||||
{
|
||||
E9 e (filt);
|
||||
|
||||
std::vector <Task>::iterator task;
|
||||
std::vector <Task>::const_iterator task;
|
||||
for (task = input.begin (); task != input.end (); ++task)
|
||||
if (e.evalFilter (*task))
|
||||
output.push_back (*task);
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
virtual int execute (std::string&) = 0;
|
||||
|
||||
protected:
|
||||
void filter (std::vector <Task>&, std::vector <Task>&);
|
||||
void filter (const std::vector <Task>&, std::vector <Task>&);
|
||||
void filter (std::vector <Task>&);
|
||||
bool filter_shortcut (const A3&);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user