From 986041dcba72f8b13463bcb423ceaa82cca30acf Mon Sep 17 00:00:00 2001 From: Thomas Lauf Date: Fri, 19 Jan 2018 15:32:21 +0100 Subject: [PATCH] TI-102: Fix interval flattening in CmdStart - set correct range for exclusion retrieval - report on added intervals not on entered --- src/commands/CmdStart.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/commands/CmdStart.cpp b/src/commands/CmdStart.cpp index f08c100f..a2260cf1 100644 --- a/src/commands/CmdStart.cpp +++ b/src/commands/CmdStart.cpp @@ -24,10 +24,8 @@ // //////////////////////////////////////////////////////////////////////////////// -#include #include #include -#include #include //////////////////////////////////////////////////////////////////////////////// @@ -37,12 +35,10 @@ int CmdStart ( Database& database) { // Add a new open interval, which may have a defined start time. - auto filter = getFilter (cli); - auto holidays = subset (filter.range, getHolidays (rules)); - auto exclusions = getAllExclusions (rules, filter.range); + auto filter = getFilter (cli); + auto latest = getLatestInterval (database); // If the latest interval is open, close it. - auto latest = getLatestInterval (database); if (latest.range.is_open ()) { // If the new interval tags match those of the currently open interval, then @@ -64,13 +60,15 @@ int CmdStart ( // Update database. database.deleteInterval (latest); - for (auto& interval : flatten (modified, exclusions)) + validate (cli, rules, database, modified); + + for (auto& interval : flatten (modified, getAllExclusions (rules, modified.range))) { database.addInterval (interval); - } - if (rules.getBoolean ("verbose")) - std::cout << intervalSummarize (database, rules, modified); + if (rules.getBoolean ("verbose")) + std::cout << intervalSummarize (database, rules, interval); + } } // Now add the new open interval.