mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Add check whether requested intervals have been found when searching by ID
- Restores behaviour which got lost when switching to the new interval filtering in 9968b9e9
- Add test for each command
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
c2e26a989e
commit
993ae85d5c
22 changed files with 329 additions and 8 deletions
|
@ -68,6 +68,27 @@ int CmdAnnotate (
|
|||
{
|
||||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
intervals = getTracked (database, rules, filtering);
|
||||
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply annotation to intervals.
|
||||
|
|
|
@ -53,6 +53,28 @@ int CmdDelete (
|
|||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
auto intervals = getTracked (database, rules, filtering);
|
||||
|
||||
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& interval : intervals)
|
||||
{
|
||||
database.deleteInterval (interval);
|
||||
|
|
|
@ -57,6 +57,27 @@ int CmdJoin (
|
|||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
auto intervals = getTracked (database, rules, filtering);
|
||||
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Interval first = intervals[1];
|
||||
Interval second = intervals[0];
|
||||
|
||||
|
|
|
@ -58,6 +58,27 @@ int CmdLengthen (
|
|||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
auto intervals = getTracked (database, rules, filtering);
|
||||
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Lengthen intervals specified by ids
|
||||
for (auto& interval : intervals)
|
||||
{
|
||||
|
|
|
@ -70,6 +70,28 @@ int CmdMove (
|
|||
|
||||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
auto intervals = getTracked (database, rules, filtering);
|
||||
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Interval interval = intervals.at (0);
|
||||
|
||||
if (interval.synthetic)
|
||||
|
|
|
@ -56,7 +56,27 @@ int CmdResize (
|
|||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
auto intervals = getTracked (database, rules, filtering);
|
||||
|
||||
// Apply tags to ids.
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (auto& interval : intervals)
|
||||
{
|
||||
if (interval.is_open ())
|
||||
|
|
|
@ -57,6 +57,27 @@ int CmdShorten (
|
|||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
auto intervals = getTracked (database, rules, filtering);
|
||||
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Shorten intervals specified by ids
|
||||
for (auto& interval : intervals)
|
||||
{
|
||||
|
|
|
@ -54,7 +54,27 @@ int CmdSplit (
|
|||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
auto intervals = getTracked (database, rules, filtering);
|
||||
|
||||
// Apply tags to ids.
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& interval : intervals)
|
||||
{
|
||||
Interval first = interval;
|
||||
|
|
|
@ -78,6 +78,27 @@ int CmdTag (
|
|||
{
|
||||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
intervals = getTracked (database, rules, filtering);
|
||||
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Apply tags to intervals.
|
||||
|
|
|
@ -77,6 +77,27 @@ int CmdUntag (
|
|||
{
|
||||
auto filtering = IntervalFilterAllWithIds (ids);
|
||||
intervals = getTracked (database, rules, filtering);
|
||||
|
||||
if (intervals.size () != ids.size ())
|
||||
{
|
||||
for (auto& id: ids)
|
||||
{
|
||||
bool found = false;
|
||||
|
||||
for (auto& interval: intervals)
|
||||
{
|
||||
if (interval.id == id)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove tags from intervals.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue