mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
TI-68: Let commands convert synthetic intervals before modifying them
- command 'lengthen' - command 'move' - command 'shorten' - command 'tag' - command 'untag'
This commit is contained in:
parent
52853db6bd
commit
9b0f8e8c15
5 changed files with 108 additions and 2 deletions
|
@ -59,7 +59,30 @@ int CmdLengthen (
|
|||
Interval filter;
|
||||
auto tracked = getTracked (database, rules, filter);
|
||||
|
||||
// Apply tags to ids.
|
||||
bool dirty = true;
|
||||
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
|
||||
if (tracked[tracked.size() - id].synthetic && dirty)
|
||||
{
|
||||
auto latest = getLatestInterval(database);
|
||||
auto exclusions = getAllExclusions (rules, filter.range);
|
||||
|
||||
Interval modified {latest};
|
||||
|
||||
// Update database.
|
||||
database.deleteInterval (latest);
|
||||
for (auto& interval : flatten (modified, exclusions))
|
||||
database.addInterval (interval);
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Lengthen intervals specified by ids
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
|
|
|
@ -64,9 +64,23 @@ int CmdMove (
|
|||
Interval filter;
|
||||
auto tracked = getTracked (database, rules, filter);
|
||||
|
||||
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
|
||||
if (tracked[tracked.size() - id].synthetic)
|
||||
{
|
||||
auto latest = getLatestInterval(database);
|
||||
auto exclusions = getAllExclusions (rules, filter.range);
|
||||
|
||||
Interval modified {latest};
|
||||
|
||||
// Update database.
|
||||
database.deleteInterval (latest);
|
||||
for (auto& interval : flatten (modified, exclusions))
|
||||
database.addInterval (interval);
|
||||
}
|
||||
|
||||
// Move start time.
|
||||
Interval i = tracked[tracked.size () - id];
|
||||
Datetime start (new_start);
|
||||
|
|
|
@ -59,7 +59,30 @@ int CmdShorten (
|
|||
Interval filter;
|
||||
auto tracked = getTracked (database, rules, filter);
|
||||
|
||||
// Apply tags to ids.
|
||||
bool dirty = true;
|
||||
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
|
||||
if (tracked[tracked.size() - id].synthetic && dirty)
|
||||
{
|
||||
auto latest = getLatestInterval(database);
|
||||
auto exclusions = getAllExclusions (rules, filter.range);
|
||||
|
||||
Interval modified {latest};
|
||||
|
||||
// Update database.
|
||||
database.deleteInterval (latest);
|
||||
for (auto& interval : flatten (modified, exclusions))
|
||||
database.addInterval (interval);
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Shorten intervals specified by ids
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
|
|
|
@ -57,6 +57,29 @@ int CmdTag (
|
|||
Interval filter;
|
||||
auto tracked = getTracked (database, rules, filter);
|
||||
|
||||
bool dirty = true;
|
||||
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
|
||||
if (tracked[tracked.size() - id].synthetic && dirty)
|
||||
{
|
||||
auto latest = getLatestInterval(database);
|
||||
auto exclusions = getAllExclusions (rules, filter.range);
|
||||
|
||||
Interval modified {latest};
|
||||
|
||||
// Update database.
|
||||
database.deleteInterval (latest);
|
||||
for (auto& interval : flatten (modified, exclusions))
|
||||
database.addInterval (interval);
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply tags to ids.
|
||||
for (auto& id : ids)
|
||||
{
|
||||
|
|
|
@ -57,6 +57,29 @@ int CmdUntag (
|
|||
Interval filter;
|
||||
auto tracked = getTracked (database, rules, filter);
|
||||
|
||||
bool dirty = true;
|
||||
|
||||
for (auto& id : ids)
|
||||
{
|
||||
if (id > static_cast <int> (tracked.size ()))
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
|
||||
if (tracked[tracked.size() - id].synthetic && dirty)
|
||||
{
|
||||
auto latest = getLatestInterval(database);
|
||||
auto exclusions = getAllExclusions (rules, filter.range);
|
||||
|
||||
Interval modified {latest};
|
||||
|
||||
// Update database.
|
||||
database.deleteInterval (latest);
|
||||
for (auto& interval : flatten (modified, exclusions))
|
||||
database.addInterval (interval);
|
||||
|
||||
dirty = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply tags to ids.
|
||||
for (auto& id : ids)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue