mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-06-26 10:54:28 +02:00
helper: Added Rules to createTimelineFromData
This commit is contained in:
parent
500fa9784a
commit
9c91cb599b
6 changed files with 26 additions and 20 deletions
|
@ -36,7 +36,7 @@ int CmdExport (
|
||||||
Database& database)
|
Database& database)
|
||||||
{
|
{
|
||||||
auto filter = createFilterIntervalFromCLI (cli);
|
auto filter = createFilterIntervalFromCLI (cli);
|
||||||
auto timeline = createTimelineFromData (database, filter);
|
auto timeline = createTimelineFromData (rules, database, filter);
|
||||||
std::cout << jsonFromIntervals (timeline.tracked (rules));
|
std::cout << jsonFromIntervals (timeline.tracked (rules));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ int CmdReport (
|
||||||
|
|
||||||
// Filter the data.
|
// Filter the data.
|
||||||
auto filter = createFilterIntervalFromCLI (cli);
|
auto filter = createFilterIntervalFromCLI (cli);
|
||||||
auto timeline = createTimelineFromData (database, filter);
|
auto timeline = createTimelineFromData (rules, database, filter);
|
||||||
auto intervals = timeline.tracked (rules);
|
auto intervals = timeline.tracked (rules);
|
||||||
|
|
||||||
// Compose Header info.
|
// Compose Header info.
|
||||||
|
|
|
@ -53,7 +53,7 @@ int CmdReportDay (
|
||||||
filter.range = Range (Datetime ("today"), Datetime ("tomorrow"));
|
filter.range = Range (Datetime ("today"), Datetime ("tomorrow"));
|
||||||
|
|
||||||
// Load the data.
|
// Load the data.
|
||||||
auto timeline = createTimelineFromData (database, filter);
|
auto timeline = createTimelineFromData (rules, database, filter);
|
||||||
auto tracked = timeline.tracked (rules);
|
auto tracked = timeline.tracked (rules);
|
||||||
auto excluded = timeline.excluded (rules);
|
auto excluded = timeline.excluded (rules);
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ int CmdReportSummary (
|
||||||
filter.range = Range (Datetime ("today"), Datetime ("tomorrow"));
|
filter.range = Range (Datetime ("today"), Datetime ("tomorrow"));
|
||||||
|
|
||||||
// Load the data.
|
// Load the data.
|
||||||
auto timeline = createTimelineFromData (database, filter);
|
auto timeline = createTimelineFromData (rules, database, filter);
|
||||||
auto tracked = timeline.tracked (rules);
|
auto tracked = timeline.tracked (rules);
|
||||||
auto excluded = timeline.excluded (rules);
|
auto excluded = timeline.excluded (rules);
|
||||||
|
|
||||||
|
|
|
@ -297,6 +297,7 @@ Interval createFilterIntervalFromCLI (const CLI& cli)
|
||||||
// We really only need to eliminate A and F.
|
// We really only need to eliminate A and F.
|
||||||
//
|
//
|
||||||
Timeline createTimelineFromData (
|
Timeline createTimelineFromData (
|
||||||
|
const Rules& rules,
|
||||||
Database& database,
|
Database& database,
|
||||||
const Interval& filter)
|
const Interval& filter)
|
||||||
{
|
{
|
||||||
|
@ -306,22 +307,27 @@ Timeline createTimelineFromData (
|
||||||
// Add filtered intervals.
|
// Add filtered intervals.
|
||||||
for (auto& line : database.allLines ())
|
for (auto& line : database.allLines ())
|
||||||
{
|
{
|
||||||
if (line[0] == 'i')
|
Interval i;
|
||||||
{
|
i.initialize (line);
|
||||||
Interval i;
|
if (intervalMatchesFilterInterval (i, filter))
|
||||||
i.initialize (line);
|
t.include (i);
|
||||||
|
}
|
||||||
|
|
||||||
if (intervalMatchesFilterInterval (i, filter))
|
// Add exclusions from configuration.
|
||||||
t.include (i);
|
for (auto& name : rules.all ("exclusions."))
|
||||||
}
|
{
|
||||||
else if (line[0] == 'e')
|
name = lowerCase (name);
|
||||||
{
|
/*
|
||||||
// Exclusions are not filtered, so they all match. This makes sure that
|
std::string line = "exc ";
|
||||||
// the correct exclusions are lined up ahead of the intervals.
|
if (name.substr (0, 16) == "exclusions.days.")
|
||||||
Exclusion e;
|
line += "day " + rules.get (name) + " " + name.substr (16);
|
||||||
e.initialize (line);
|
else
|
||||||
t.exclude (e);
|
line += name.substr (11) + " " + rules.get (name);
|
||||||
}
|
|
||||||
|
// TODO Convert Exclusion::initialize to parse the line directly out of the
|
||||||
|
// rules.
|
||||||
|
*/
|
||||||
|
t.exclude (Exclusion (name, rules.get (name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -49,7 +49,7 @@ Color tagColor (const Rules&, const std::string&);
|
||||||
std::string intervalSummarize (const Rules&, const Interval&);
|
std::string intervalSummarize (const Rules&, const Interval&);
|
||||||
bool expandIntervalHint (const std::string&, std::string&, std::string&);
|
bool expandIntervalHint (const std::string&, std::string&, std::string&);
|
||||||
Interval createFilterIntervalFromCLI (const CLI&);
|
Interval createFilterIntervalFromCLI (const CLI&);
|
||||||
Timeline createTimelineFromData (Database&, const Interval&);
|
Timeline createTimelineFromData (const Rules&, Database&, const Interval&);
|
||||||
Interval getLatestInterval (Database&);
|
Interval getLatestInterval (Database&);
|
||||||
bool intervalMatchesFilterInterval (const Interval&, const Interval&);
|
bool intervalMatchesFilterInterval (const Interval&, const Interval&);
|
||||||
std::string jsonFromIntervals (const std::vector <Interval>&);
|
std::string jsonFromIntervals (const std::vector <Interval>&);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue