mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Enhancement - timesheet report
- Version 1 of the timesheet report. Displays a specified number of weeks tasks, both started and completed.
This commit is contained in:
parent
4ab665b876
commit
fd823871f0
5 changed files with 142 additions and 41 deletions
|
@ -25,6 +25,8 @@
|
||||||
example "task oldest 5" will display the 5 oldest tasks.
|
example "task oldest 5" will display the 5 oldest tasks.
|
||||||
+ Modified the "stats" report so that it has the same aesthetics as the
|
+ Modified the "stats" report so that it has the same aesthetics as the
|
||||||
other reports.
|
other reports.
|
||||||
|
+ New "timesheet" command displays tasks completed and started, per week,
|
||||||
|
and can display multiple weeks.
|
||||||
|
|
||||||
------ old releases ------------------------------
|
------ old releases ------------------------------
|
||||||
|
|
||||||
|
|
|
@ -231,9 +231,16 @@ Year Month Added Completed Deleted Net
|
||||||
report. It shows a colored bar graph and legend.
|
report. It shows a colored bar graph and legend.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<strong>% task timesheet</strong>
|
<strong>% task timesheet 2</strong>
|
||||||
<p>
|
<p>
|
||||||
???
|
The timesheet report shows a list of tasks completed and started
|
||||||
|
during a one-week period. In the example above, 2 weeks of tasks
|
||||||
|
are shown.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
By default, the report starts on a Monday. To override this
|
||||||
|
value, add an entry to your .taskrc file like this:
|
||||||
|
<pre><code>weekstart=Sunday</code></pre>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<strong>% task calendar</strong>
|
<strong>% task calendar</strong>
|
||||||
|
|
|
@ -164,36 +164,14 @@
|
||||||
example "task oldest 5" will display the 5 oldest tasks.
|
example "task oldest 5" will display the 5 oldest tasks.
|
||||||
<li>Modified the "stats" report so that it has the same aesthetics as the
|
<li>Modified the "stats" report so that it has the same aesthetics as the
|
||||||
other reports.
|
other reports.
|
||||||
|
<li>New "timesheet" command displays tasks completed and started, per week,
|
||||||
|
and can display multiple weeks.
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
(Find out <a href="versions.html">what was new in prior versions</a>)
|
(Find out <a href="versions.html">what was new in prior versions</a>)
|
||||||
</p>
|
</p>
|
||||||
<!--
|
|
||||||
<h2>Task 1.7.0 Beta</h2>
|
|
||||||
<p>
|
|
||||||
The next version of task is in beta. This means it is approaching the
|
|
||||||
end of the current development and testing cycle, and feedback from
|
|
||||||
a wider audience is needed to find the last bugs. If you would like
|
|
||||||
to help test the next release of task, download the beta source below
|
|
||||||
and install in the usual manner.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Please note that beta software may contain significant bugs. If you
|
|
||||||
use this beta release, you should first backup your existing task
|
|
||||||
data files.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Refer to the ChangeLog file for details regarding the various fixes
|
|
||||||
and enhancements.
|
|
||||||
</p>
|
|
||||||
<table>
|
|
||||||
<tr>
|
|
||||||
<td>Source:</td>
|
|
||||||
<td><a href="http://www.beckingham.net/task-1.7.0beta.tar.gz">task-1.7.0beta.tar.gz</a></td>
|
|
||||||
</tr>
|
|
||||||
</table>
|
|
||||||
-->
|
|
||||||
<h2>Troubleshooting</h2>
|
<h2>Troubleshooting</h2>
|
||||||
<p>
|
<p>
|
||||||
Task has been built from source and tested in the following environments:
|
Task has been built from source and tested in the following environments:
|
||||||
|
|
140
src/report.cpp
140
src/report.cpp
|
@ -1346,42 +1346,156 @@ std::string handleReportTimesheet (TDB& tdb, T& task, Config& conf)
|
||||||
|
|
||||||
for (int week = 0; week < quantity; ++week)
|
for (int week = 0; week < quantity; ++week)
|
||||||
{
|
{
|
||||||
out << start.toString (conf.get ("dateformat", "m/d/Y"))
|
out << std::endl
|
||||||
|
<< Text::colorize (Text::bold, Text::nocolor)
|
||||||
|
<< start.toString (conf.get ("dateformat", "m/d/Y"))
|
||||||
<< " - "
|
<< " - "
|
||||||
<< end.toString (conf.get ("dateformat", "m/d/Y"))
|
<< end.toString (conf.get ("dateformat", "m/d/Y"))
|
||||||
|
<< Text::colorize ()
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
|
|
||||||
// Render the completed table.
|
// Render the completed table.
|
||||||
Table completed;
|
Table completed;
|
||||||
|
completed.setTableWidth (width);
|
||||||
|
completed.addColumn (" ");
|
||||||
|
completed.addColumn ("Project");
|
||||||
|
completed.addColumn ("Due");
|
||||||
|
completed.addColumn ("Description");
|
||||||
|
|
||||||
|
completed.setColumnUnderline (1);
|
||||||
|
completed.setColumnUnderline (2);
|
||||||
|
completed.setColumnUnderline (3);
|
||||||
|
|
||||||
|
completed.setColumnWidth (0, Table::minimum);
|
||||||
|
completed.setColumnWidth (1, Table::minimum);
|
||||||
|
completed.setColumnWidth (2, Table::minimum);
|
||||||
|
completed.setColumnWidth (3, Table::flexible);
|
||||||
|
|
||||||
|
completed.setColumnJustification (0, Table::left);
|
||||||
|
completed.setColumnJustification (1, Table::left);
|
||||||
|
completed.setColumnJustification (2, Table::right);
|
||||||
|
completed.setColumnJustification (3, Table::left);
|
||||||
|
|
||||||
foreach (t, tasks)
|
foreach (t, tasks)
|
||||||
{
|
{
|
||||||
// TODO If task completed within range.
|
// If task completed within range.
|
||||||
|
if (t->getStatus () == T::completed)
|
||||||
|
{
|
||||||
|
Date compDate (::atoi (t->getAttribute ("end").c_str ()));
|
||||||
|
if (compDate >= start && compDate < end)
|
||||||
|
{
|
||||||
|
int row = completed.addRow ();
|
||||||
|
completed.addCell (row, 1, t->getAttribute ("project"));
|
||||||
|
|
||||||
|
std::string due = t->getAttribute ("due");
|
||||||
|
if (due.length ())
|
||||||
|
{
|
||||||
|
Date d (::atoi (due.c_str ()));
|
||||||
|
due = d.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
|
completed.addCell (row, 2, due);
|
||||||
}
|
}
|
||||||
|
|
||||||
out << " Completed (" << completed.rowCount () << ")" << std::endl;
|
std::string description = t->getDescription ();
|
||||||
|
std::string when;
|
||||||
|
std::map <time_t, std::string> annotations;
|
||||||
|
t->getAnnotations (annotations);
|
||||||
|
foreach (anno, annotations)
|
||||||
|
{
|
||||||
|
Date dt (anno->first);
|
||||||
|
when = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
|
description += "\n" + when + " " + anno->second;
|
||||||
|
}
|
||||||
|
completed.addCell (row, 3, description);
|
||||||
|
|
||||||
|
if (conf.get ("color", true) || conf.get (std::string ("_forcecolor"), false))
|
||||||
|
{
|
||||||
|
Text::color fg = Text::colorCode (t->getAttribute ("fg"));
|
||||||
|
Text::color bg = Text::colorCode (t->getAttribute ("bg"));
|
||||||
|
autoColorize (*t, fg, bg, conf);
|
||||||
|
completed.setRowFg (row, fg);
|
||||||
|
completed.setRowBg (row, bg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out << " Completed (" << completed.rowCount () << " tasks)" << std::endl;
|
||||||
|
|
||||||
if (completed.rowCount ())
|
if (completed.rowCount ())
|
||||||
out << optionalBlankLine (conf)
|
out << completed.render ()
|
||||||
<< completed.render ()
|
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else
|
|
||||||
out << " None" << std::endl;
|
|
||||||
|
|
||||||
// Now render the started table.
|
// Now render the started table.
|
||||||
Table started;
|
Table started;
|
||||||
|
started.setTableWidth (width);
|
||||||
|
started.addColumn (" ");
|
||||||
|
started.addColumn ("Project");
|
||||||
|
started.addColumn ("Due");
|
||||||
|
started.addColumn ("Description");
|
||||||
|
|
||||||
|
started.setColumnUnderline (1);
|
||||||
|
started.setColumnUnderline (2);
|
||||||
|
started.setColumnUnderline (3);
|
||||||
|
|
||||||
|
started.setColumnWidth (0, Table::minimum);
|
||||||
|
started.setColumnWidth (1, Table::minimum);
|
||||||
|
started.setColumnWidth (2, Table::minimum);
|
||||||
|
started.setColumnWidth (3, Table::flexible);
|
||||||
|
|
||||||
|
started.setColumnJustification (0, Table::left);
|
||||||
|
started.setColumnJustification (1, Table::left);
|
||||||
|
started.setColumnJustification (2, Table::right);
|
||||||
|
started.setColumnJustification (3, Table::left);
|
||||||
foreach (t, tasks)
|
foreach (t, tasks)
|
||||||
{
|
{
|
||||||
// TODO If task started withing range, but not completed withing range.
|
// If task started within range, but not completed withing range.
|
||||||
|
if (t->getStatus () == T::pending &&
|
||||||
|
t->getAttribute ("start") != "")
|
||||||
|
{
|
||||||
|
Date startDate (::atoi (t->getAttribute ("start").c_str ()));
|
||||||
|
if (startDate >= start && startDate < end)
|
||||||
|
{
|
||||||
|
int row = started.addRow ();
|
||||||
|
started.addCell (row, 1, t->getAttribute ("project"));
|
||||||
|
|
||||||
|
std::string due = t->getAttribute ("due");
|
||||||
|
if (due.length ())
|
||||||
|
{
|
||||||
|
Date d (::atoi (due.c_str ()));
|
||||||
|
due = d.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
|
started.addCell (row, 2, due);
|
||||||
}
|
}
|
||||||
|
|
||||||
out << " Started (" << started.rowCount () << ")" << std::endl;
|
std::string description = t->getDescription ();
|
||||||
|
std::string when;
|
||||||
|
std::map <time_t, std::string> annotations;
|
||||||
|
t->getAnnotations (annotations);
|
||||||
|
foreach (anno, annotations)
|
||||||
|
{
|
||||||
|
Date dt (anno->first);
|
||||||
|
when = dt.toString (conf.get ("dateformat", "m/d/Y"));
|
||||||
|
description += "\n" + when + " " + anno->second;
|
||||||
|
}
|
||||||
|
started.addCell (row, 3, description);
|
||||||
|
|
||||||
|
if (conf.get ("color", true) || conf.get (std::string ("_forcecolor"), false))
|
||||||
|
{
|
||||||
|
Text::color fg = Text::colorCode (t->getAttribute ("fg"));
|
||||||
|
Text::color bg = Text::colorCode (t->getAttribute ("bg"));
|
||||||
|
autoColorize (*t, fg, bg, conf);
|
||||||
|
started.setRowFg (row, fg);
|
||||||
|
started.setRowBg (row, bg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
out << " Started (" << started.rowCount () << " tasks)" << std::endl;
|
||||||
|
|
||||||
if (started.rowCount ())
|
if (started.rowCount ())
|
||||||
out << optionalBlankLine (conf)
|
out << started.render ()
|
||||||
<< started.render ()
|
<< std::endl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
else
|
|
||||||
out << " None" << std::endl;
|
|
||||||
|
|
||||||
// Prior week.
|
// Prior week.
|
||||||
start -= 7 * 86400;
|
start -= 7 * 86400;
|
||||||
|
|
|
@ -153,7 +153,7 @@ static std::string shortUsage (Config& conf)
|
||||||
table.addCell (row, 2, "Shows a report of task status by project");
|
table.addCell (row, 2, "Shows a report of task status by project");
|
||||||
|
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
table.addCell (row, 1, "task timesheet [duration]");
|
table.addCell (row, 1, "task timesheet [weeks]");
|
||||||
table.addCell (row, 2, "Shows a weekly report of tasks completed and started");
|
table.addCell (row, 2, "Shows a weekly report of tasks completed and started");
|
||||||
|
|
||||||
row = table.addRow ();
|
row = table.addRow ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue