Skip to content

Commit

Permalink
Merge branch 'summarize-only-current-interval' into sruffell-active
Browse files Browse the repository at this point in the history
  • Loading branch information
sruffell committed Aug 14, 2020
2 parents d40cc91 + 89c29c4 commit 850773d
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 850773d

Please sign in to comment.