diff --git a/src/commands/CmdExport.cpp b/src/commands/CmdExport.cpp index dc2fd00e..cf7588a8 100644 --- a/src/commands/CmdExport.cpp +++ b/src/commands/CmdExport.cpp @@ -36,7 +36,7 @@ int CmdExport ( Database& database) { auto filter = createFilterIntervalFromCLI (cli); - auto timeline = createTimelineFromData (database, filter); + auto timeline = createTimelineFromData (rules, database, filter); std::cout << jsonFromIntervals (timeline.tracked (rules)); return 0; } diff --git a/src/commands/CmdReport.cpp b/src/commands/CmdReport.cpp index 43db85d3..a05d6dc6 100644 --- a/src/commands/CmdReport.cpp +++ b/src/commands/CmdReport.cpp @@ -80,7 +80,7 @@ int CmdReport ( // Filter the data. auto filter = createFilterIntervalFromCLI (cli); - auto timeline = createTimelineFromData (database, filter); + auto timeline = createTimelineFromData (rules, database, filter); auto intervals = timeline.tracked (rules); // Compose Header info. diff --git a/src/commands/CmdReportDay.cpp b/src/commands/CmdReportDay.cpp index e1bb0c4b..7dbefa7e 100644 --- a/src/commands/CmdReportDay.cpp +++ b/src/commands/CmdReportDay.cpp @@ -53,7 +53,7 @@ int CmdReportDay ( filter.range = Range (Datetime ("today"), Datetime ("tomorrow")); // Load the data. - auto timeline = createTimelineFromData (database, filter); + auto timeline = createTimelineFromData (rules, database, filter); auto tracked = timeline.tracked (rules); auto excluded = timeline.excluded (rules); diff --git a/src/commands/CmdReportSummary.cpp b/src/commands/CmdReportSummary.cpp index 3050e933..79eeede2 100644 --- a/src/commands/CmdReportSummary.cpp +++ b/src/commands/CmdReportSummary.cpp @@ -42,7 +42,7 @@ int CmdReportSummary ( filter.range = Range (Datetime ("today"), Datetime ("tomorrow")); // Load the data. - auto timeline = createTimelineFromData (database, filter); + auto timeline = createTimelineFromData (rules, database, filter); auto tracked = timeline.tracked (rules); auto excluded = timeline.excluded (rules); diff --git a/src/helper.cpp b/src/helper.cpp index bc908f6f..2bf6b29f 100644 --- a/src/helper.cpp +++ b/src/helper.cpp @@ -297,6 +297,7 @@ Interval createFilterIntervalFromCLI (const CLI& cli) // We really only need to eliminate A and F. // Timeline createTimelineFromData ( + const Rules& rules, Database& database, const Interval& filter) { @@ -306,22 +307,27 @@ Timeline createTimelineFromData ( // Add filtered intervals. for (auto& line : database.allLines ()) { - if (line[0] == 'i') - { - Interval i; - i.initialize (line); + Interval i; + i.initialize (line); + if (intervalMatchesFilterInterval (i, filter)) + t.include (i); + } - if (intervalMatchesFilterInterval (i, filter)) - t.include (i); - } - else if (line[0] == 'e') - { - // Exclusions are not filtered, so they all match. This makes sure that - // the correct exclusions are lined up ahead of the intervals. - Exclusion e; - e.initialize (line); - t.exclude (e); - } + // Add exclusions from configuration. + for (auto& name : rules.all ("exclusions.")) + { + name = lowerCase (name); +/* + std::string line = "exc "; + if (name.substr (0, 16) == "exclusions.days.") + line += "day " + rules.get (name) + " " + name.substr (16); + else + 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; diff --git a/src/timew.h b/src/timew.h index 13ee12b8..43185812 100644 --- a/src/timew.h +++ b/src/timew.h @@ -49,7 +49,7 @@ Color tagColor (const Rules&, const std::string&); std::string intervalSummarize (const Rules&, const Interval&); bool expandIntervalHint (const std::string&, std::string&, std::string&); Interval createFilterIntervalFromCLI (const CLI&); -Timeline createTimelineFromData (Database&, const Interval&); +Timeline createTimelineFromData (const Rules&, Database&, const Interval&); Interval getLatestInterval (Database&); bool intervalMatchesFilterInterval (const Interval&, const Interval&); std::string jsonFromIntervals (const std::vector &);