mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
intervalSummarize should not load the entire database
intervalSummarize is called at the end of most commands. The cost of parsing all the lines in the database can be significant as the size of the database grows. Related to issue #245.
This commit is contained in:
parent
6af1101ea2
commit
cf8c35ad55
1 changed files with 10 additions and 5 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include <format.h>
|
#include <format.h>
|
||||||
#include <Datetime.h>
|
#include <Datetime.h>
|
||||||
#include <Duration.h>
|
#include <Duration.h>
|
||||||
|
#include <IntervalFactory.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -85,13 +86,17 @@ std::string intervalSummarize (
|
||||||
// in the most recent set of intervals for the same tags. This is the
|
// in the most recent set of intervals for the same tags. This is the
|
||||||
// acceptable definition of "the current task".
|
// acceptable definition of "the current task".
|
||||||
time_t total_recorded = 0;
|
time_t total_recorded = 0;
|
||||||
auto inclusions = getAllInclusions (database);
|
|
||||||
std::vector <Interval>::reverse_iterator i;
|
auto i = database.rbegin ();
|
||||||
for (i = inclusions.rbegin (); i != inclusions.rend (); i++)
|
auto end = database.rend ();
|
||||||
if (interval.tags () == i->tags ())
|
for (; i != end; ++i)
|
||||||
total_recorded += i->total ();
|
{
|
||||||
|
Interval current = IntervalFactory::fromSerialization (*i);
|
||||||
|
if (interval.tags () == current.tags ())
|
||||||
|
total_recorded += current.total ();
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
Duration total (total_recorded);
|
Duration total (total_recorded);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue