mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
CmdReportDay: Made summary rendering configurable
This commit is contained in:
parent
1b94a3fad7
commit
4c0da0d77f
1 changed files with 27 additions and 7 deletions
|
@ -27,6 +27,7 @@
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <Composite.h>
|
#include <Composite.h>
|
||||||
#include <Color.h>
|
#include <Color.h>
|
||||||
|
#include <Duration.h>
|
||||||
#include <Range.h>
|
#include <Range.h>
|
||||||
#include <commands.h>
|
#include <commands.h>
|
||||||
#include <timew.h>
|
#include <timew.h>
|
||||||
|
@ -34,11 +35,12 @@
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
static void renderSummary (const std::string&);
|
|
||||||
static void renderAxis (const Rules&, Palette&, const std::string&, int, int);
|
static void renderAxis (const Rules&, Palette&, const std::string&, int, int);
|
||||||
static void renderExclusionBlocks (const Rules&, Composite&, Composite&, Palette&, const Datetime&, int, int, const std::vector <Range>&);
|
static void renderExclusionBlocks (const Rules&, Composite&, Composite&, Palette&, const Datetime&, int, int, const std::vector <Range>&);
|
||||||
static void renderInterval (const Rules&, Composite&, Composite&, const Datetime&, const Interval&, int, Palette&, std::map <std::string, Color>&);
|
static void renderInterval (const Rules&, Composite&, Composite&, const Datetime&, const Interval&, int, Palette&, std::map <std::string, Color>&);
|
||||||
|
static void renderSummary (const std::string&, const std::vector <Range>&, const std::vector <Interval>&);
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
int CmdReportDay (
|
int CmdReportDay (
|
||||||
|
@ -109,7 +111,9 @@ int CmdReportDay (
|
||||||
<< '\n';
|
<< '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
renderSummary (indent);
|
if (rules.getBoolean ("report.day.summary"))
|
||||||
|
renderSummary (indent, exclusions, tracked);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,12 +265,28 @@ static void renderInterval (
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
static void renderSummary (const std::string& indent)
|
static void renderSummary (
|
||||||
|
const std::string& indent,
|
||||||
|
const std::vector <Range>& exclusions,
|
||||||
|
const std::vector <Interval>& tracked)
|
||||||
{
|
{
|
||||||
// TODO Summary, missing.
|
time_t unavailable = 0;
|
||||||
std::cout << indent << "Tracked\n"
|
for (auto& exclusion : exclusions)
|
||||||
<< indent << "Untracked\n"
|
unavailable += exclusion.total ();
|
||||||
<< indent << "Total\n"
|
|
||||||
|
time_t worked = 0;
|
||||||
|
for (auto& interval : tracked)
|
||||||
|
worked += interval.range.total ();
|
||||||
|
|
||||||
|
auto all_day = 86400 - unavailable;
|
||||||
|
auto remaining = all_day - worked;
|
||||||
|
|
||||||
|
std::cout << indent << "Tracked "
|
||||||
|
<< std::setw (13) << std::setfill (' ') << Duration (worked).format () << '\n'
|
||||||
|
<< indent << "Remaining "
|
||||||
|
<< std::setw (13) << std::setfill (' ') << Duration (remaining).format () << '\n'
|
||||||
|
<< indent << "Total "
|
||||||
|
<< std::setw (13) << std::setfill (' ') << Duration (all_day).format () << '\n'
|
||||||
<< '\n';
|
<< '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue