mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug - timesheet
- Converted the timesheet report to use raw word arguments instead of filters. - Uses new TDB2:all_tasks method. - Cleaned up unit tests.
This commit is contained in:
parent
195c7d5142
commit
297ec6dd1f
2 changed files with 29 additions and 43 deletions
|
@ -52,13 +52,9 @@ int CmdTimesheet::execute (std::string& output)
|
|||
|
||||
// Scan the pending tasks.
|
||||
handleRecurrence ();
|
||||
std::vector <Task> filtered;
|
||||
filter (filtered);
|
||||
std::vector <Task> 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 <std::string> 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 <Task>::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 &&
|
||||
|
|
|
@ -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')
|
||||
|
@ -51,22 +51,22 @@ if (open my $fh, '>', 'time.rc')
|
|||
# C1 completed, last week
|
||||
# C2 completed, 2wks ago
|
||||
my $now = time ();
|
||||
my $seven = $now - 7 * 86_400;
|
||||
my $fourteen = $now - 14 * 86_400;
|
||||
my $six = $now - 6 * 86_400;
|
||||
my $twelve = $now - 12 * 86_400;
|
||||
|
||||
if (open my $fh, '>', 'pending.data')
|
||||
{
|
||||
print $fh <<EOF;
|
||||
[status:"pending" description:"P0" entry:"$fourteen"]
|
||||
[status:"pending" description:"PS0" entry:"$fourteen" start:"$now"]
|
||||
[status:"pending" description:"PS1" entry:"$fourteen" start:"$seven"]
|
||||
[status:"pending" description:"PS2" entry:"$fourteen" start:"$fourteen"]
|
||||
[status:"deleted" description:"D0" entry:"$fourteen" end:"$now"]
|
||||
[status:"deleted" description:"D1" entry:"$fourteen" end:"$seven"]
|
||||
[status:"deleted" description:"D2" entry:"$fourteen" end:"$fourteen"]
|
||||
[status:"completed" description:"C0" entry:"$fourteen" end:"$now"]
|
||||
[status:"completed" description:"C1" entry:"$fourteen" end:"$seven"]
|
||||
[status:"completed" description:"C2" entry:"$fourteen" end:"$fourteen"]
|
||||
[uuid:"00000000-0000-0000-0000-000000000000 " status:"pending" description:"P0" entry:"$twelve"]
|
||||
[uuid:"11111111-1111-1111-1111-111111111111 " status:"pending" description:"PS0" entry:"$twelve" start:"$now"]
|
||||
[uuid:"22222222-2222-2222-2222-222222222222 " status:"pending" description:"PS1" entry:"$twelve" start:"$six"]
|
||||
[uuid:"33333333-3333-3333-3333-333333333333 " status:"pending" description:"PS2" entry:"$twelve" start:"$twelve"]
|
||||
[uuid:"44444444-4444-4444-4444-444444444444 " status:"deleted" description:"D0" entry:"$twelve" end:"$now"]
|
||||
[uuid:"55555555-5555-5555-5555-555555555555 " status:"deleted" description:"D1" entry:"$twelve" end:"$six"]
|
||||
[uuid:"66666666-6666-6666-6666-666666666666 " status:"deleted" description:"D2" entry:"$twelve" end:"$twelve"]
|
||||
[uuid:"77777777-7777-7777-7777-777777777777 " status:"completed" description:"C0" entry:"$twelve" end:"$now"]
|
||||
[uuid:"88888888-8888-8888-8888-888888888888 " status:"completed" description:"C1" entry:"$twelve" end:"$six"]
|
||||
[uuid:"99999999-9999-9999-9999-999999999999 " status:"completed" description:"C2" entry:"$twelve" end:"$twelve"]
|
||||
EOF
|
||||
close $fh;
|
||||
ok (-r 'pending.data', 'Created pending.data');
|
||||
|
@ -82,23 +82,13 @@ $output = qx{../src/task rc:time.rc timesheet 3};
|
|||
like ($output, qr/Completed.+C0.+Started.+PS0.+Completed.+C1.+Started.+PS1.+Completed.+C2.+Started.+PS2/ms, 'three weeks of started and completed');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'completed.data';
|
||||
ok (!-r 'completed.data', 'Removed completed.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'backlog.data';
|
||||
ok (!-r 'backlog.data', 'Removed backlog.data');
|
||||
|
||||
unlink 'synch.key';
|
||||
ok (!-r 'synch.key', 'Removed synch.key');
|
||||
|
||||
unlink 'time.rc';
|
||||
ok (!-r 'time.rc', 'Removed time.rc');
|
||||
unlink qw(pending.data completed.data undo.data backlog.data synch.key time.rc);
|
||||
ok (! -r 'pending.data' &&
|
||||
! -r 'completed.data' &&
|
||||
! -r 'undo.data' &&
|
||||
! -r 'backlog.data' &&
|
||||
! -r 'synch_key.data' &&
|
||||
! -r 'time.rc', 'Cleanup');
|
||||
|
||||
exit 0;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue