From 297ec6dd1fb382581dccec1afb688b2c32f245c7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 5 Sep 2011 10:47:38 -0400 Subject: [PATCH] Bug - timesheet - Converted the timesheet report to use raw word arguments instead of filters. - Uses new TDB2:all_tasks method. - Cleaned up unit tests. --- src/commands/CmdTimesheet.cpp | 20 ++++++-------- test/timesheet.t | 52 ++++++++++++++--------------------- 2 files changed, 29 insertions(+), 43 deletions(-) diff --git a/src/commands/CmdTimesheet.cpp b/src/commands/CmdTimesheet.cpp index fe6003f2b..7c494d0c2 100644 --- a/src/commands/CmdTimesheet.cpp +++ b/src/commands/CmdTimesheet.cpp @@ -52,13 +52,9 @@ int CmdTimesheet::execute (std::string& output) // Scan the pending tasks. handleRecurrence (); - std::vector filtered; - filter (filtered); + std::vector all = context.tdb2.all_tasks (); context.tdb2.commit (); - // Just do this once. - int width = context.getWidth (); - // What day of the week does the user consider the first? int weekStart = Date::dayOfWeek (context.config.get ("weekstart")); if (weekStart != 0 && weekStart != 1) @@ -76,9 +72,9 @@ int CmdTimesheet::execute (std::string& output) // Determine how many reports to run. int quantity = 1; - A3 modifications = context.a3.extract_modifications (); - if (modifications.size () == 1) - quantity = strtol (modifications[0]._raw.c_str (), NULL, 10);; + std::vector words = context.a3.extract_words (); + if (words.size () == 1) + quantity = strtol (words[0].c_str (), NULL, 10);; std::stringstream out; for (int week = 0; week < quantity; ++week) @@ -97,14 +93,14 @@ int CmdTimesheet::execute (std::string& output) // Render the completed table. ViewText completed; - completed.width (width); + completed.width (context.getWidth ()); completed.add (Column::factory ("string", " ")); completed.add (Column::factory ("string", "Project")); completed.add (Column::factory ("string.right", "Due")); completed.add (Column::factory ("string", "Description")); std::vector ::iterator task; - for (task = filtered.begin (); task != filtered.end (); ++task) + for (task = all.begin (); task != all.end (); ++task) { // If task completed within range. if (task->getStatus () == Task::completed) @@ -135,13 +131,13 @@ int CmdTimesheet::execute (std::string& output) // Now render the started table. ViewText started; - started.width (width); + started.width (context.getWidth ()); started.add (Column::factory ("string", " ")); started.add (Column::factory ("string", "Project")); started.add (Column::factory ("string.right", "Due")); started.add (Column::factory ("string", "Description")); - for (task = filtered.begin (); task != filtered.end (); ++task) + for (task = all.begin (); task != all.end (); ++task) { // If task started within range, but not completed withing range. if (task->getStatus () == Task::pending && diff --git a/test/timesheet.t b/test/timesheet.t index 5ebeb1a83..a973f6baa 100755 --- a/test/timesheet.t +++ b/test/timesheet.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 11; +use Test::More tests => 6; # Create the rc file. if (open my $fh, '>', 'time.rc') @@ -50,23 +50,23 @@ if (open my $fh, '>', 'time.rc') # C0 completed, this week # C1 completed, last week # C2 completed, 2wks ago -my $now = time (); -my $seven = $now - 7 * 86_400; -my $fourteen = $now - 14 * 86_400; +my $now = time (); +my $six = $now - 6 * 86_400; +my $twelve = $now - 12 * 86_400; if (open my $fh, '>', 'pending.data') { print $fh <