Skip to content

Commit

Permalink
Use only the current interval duration when summarizing
Browse files Browse the repository at this point in the history
There are several instances where the "total" reported in the interval
summary is confusing because the summarize function would walk backward
and add all intervals with the same set of tags.

Closes GothenburgBitFactory#248 and GothenburgBitFactory#308

Signed-off-by: Shaun Ruffell <[email protected]>
  • Loading branch information
sruffell committed Aug 14, 2020
1 parent 6fe15d2 commit 89c29c4
Showing 1 changed file with 2 additions and 21 deletions.
23 changes: 2 additions & 21 deletions src/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,15 @@ Color tagColor (const Rules& rules, const std::string& tag)
////////////////////////////////////////////////////////////////////////////////
// Summarize either an active or closed interval, for user feedback.
std::string intervalSummarize (
Database& database,
Database&,
const Rules& rules,
const Interval& interval)
{
std::stringstream out;

if (interval.is_started ())
{
// Walk backwards through the inclusions, and stop as soon as the tags
// no longer match interval. This means the 'total' is the sum of all time
// in the most recent set of intervals for the same tags. This is the
// acceptable definition of "the current task".
time_t total_recorded = 0;

for (auto& line : database)
{
Interval current = IntervalFactory::fromSerialization (line);
if (interval.tags () == current.tags ())
{
total_recorded += current.total ();
}
else
{
break;
}
}

Duration total (total_recorded);
Duration total (interval.total ());

// Combine and colorize tags.
std::string tags;
Expand Down

0 comments on commit 89c29c4

Please sign in to comment.