Make TDB2.backlog non-public

The stats command gets this information from an API that will also work
for TaskChampion.  The sync command still accesses the field directly,
as the command must be completely rewritten for TaskChampion.
This commit is contained in:
Dustin J. Mitchell 2022-04-01 14:58:05 +00:00 committed by Tomas Babej
parent d699ce8cba
commit c8cfcec48b
6 changed files with 37 additions and 28 deletions

View file

@ -61,39 +61,39 @@ int main (int, char**)
std::vector <Task> pending = context.tdb2.pending.get_tasks ();
std::vector <Task> completed = context.tdb2.completed.get_tasks ();
std::vector <std::string> undo = context.tdb2.undo.get_lines ();
std::vector <std::string> backlog = context.tdb2.backlog.get_lines ();
int num_local_changes = context.tdb2.num_local_changes ();
t.is ((int) pending.size (), 0, "TDB2 Read empty pending");
t.is ((int) completed.size (), 0, "TDB2 Read empty completed");
t.is ((int) undo.size (), 0, "TDB2 Read empty undo");
t.is ((int) backlog.size (), 0, "TDB2 Read empty backlog");
t.is ((int) num_local_changes, 0, "TDB2 Read empty backlog");
// Add a task.
Task task (R"([description:"description" name:"value"])");
context.tdb2.add (task);
pending = context.tdb2.pending.get_tasks ();
completed = context.tdb2.completed.get_tasks ();
undo = context.tdb2.undo.get_lines ();
backlog = context.tdb2.backlog.get_lines ();
pending = context.tdb2.pending.get_tasks ();
completed = context.tdb2.completed.get_tasks ();
undo = context.tdb2.undo.get_lines ();
num_local_changes = context.tdb2.num_local_changes ();
t.is ((int) pending.size (), 1, "TDB2 after add, 1 pending task");
t.is ((int) completed.size (), 0, "TDB2 after add, 0 completed tasks");
t.is ((int) undo.size (), 3, "TDB2 after add, 3 undo lines");
t.is ((int) backlog.size (), 1, "TDB2 after add, 1 backlog task");
t.is ((int) num_local_changes, 1, "TDB2 after add, 1 backlog task");
task.set ("description", "This is a test");
context.tdb2.modify (task);
pending = context.tdb2.pending.get_tasks ();
completed = context.tdb2.completed.get_tasks ();
undo = context.tdb2.undo.get_lines ();
backlog = context.tdb2.backlog.get_lines ();
pending = context.tdb2.pending.get_tasks ();
completed = context.tdb2.completed.get_tasks ();
undo = context.tdb2.undo.get_lines ();
num_local_changes = context.tdb2.num_local_changes ();
t.is ((int) pending.size (), 1, "TDB2 after add, 1 pending task");
t.is ((int) completed.size (), 0, "TDB2 after add, 0 completed tasks");
t.is ((int) undo.size (), 7, "TDB2 after add, 7 undo lines");
t.is ((int) backlog.size (), 2, "TDB2 after add, 2 backlog task");
t.is ((int) num_local_changes, 2, "TDB2 after add, 2 backlog task");
context.tdb2.commit ();