CmdStop: Refactored data I/O

This commit is contained in:
Paul Beckingham 2016-04-11 08:25:48 -04:00
parent b6e5ded895
commit 6965b506e8

View file

@ -38,19 +38,20 @@ int CmdStop (
Database& database) Database& database)
{ {
// Load the most recent interval. // Load the most recent interval.
auto latest = database.getLatestInterval (); auto latest = getLatestInterval (database);
// Verify the interval is open. // Verify the interval is open.
if ( latest.isStarted () && if ( latest.isStarted () &&
! latest.isEnded ()) ! latest.isEnded ())
{ {
// Stop it. // Stop it.
latest.end (Datetime ()); auto modified {latest};
database.modifyInterval (latest); modified.end (Datetime ());
database.modifyInterval (latest, modified);
// User feedback. // User feedback.
if (rules.getBoolean ("verbose")) if (rules.getBoolean ("verbose"))
std::cout << intervalSummarize (rules, latest); std::cout << intervalSummarize (rules, modified);
// If tags were specified, and after removing those tags, there are still // If tags were specified, and after removing those tags, there are still
// tags remaining, then add a contiguous interval. // tags remaining, then add a contiguous interval.