Commit graph

97 commits

Author SHA1 Message Date
Shaun Ruffell
a98bd14d66 Simplify getIntervalsById and getTracked
The intent here is to make similar the implementations of
getIntervalsById and getTracked, since they are both gathering a
collection of intervals from the database, but they are just using a
different criteria for which ones to pull.

This also eliminates the use of std::deque.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Shaun Ruffell
73970b3755 Do not delete and then re-add the latest interval when flattening Database
Eliminates extra noise in the debug output. I.e. from #422 the original
report contained:

  >> 2021-05.data: Deleted inc 20210511T161243Z # "TRACKER-6145"
  >> 2021-05.data: Added inc 20210511T161243Z # "TRACKER-6145"

Which isn't doing anything.

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Shaun Ruffell
bba56cc633 getIntervalsById: Only add truly synthetic intervals to synthetic vector
This fixes an error where the latest interval, a non-synthetic interval,
is added to the synthetic array (and marked synthetic) if flatten() is
otherwise not able to convert it to a group of synthetic intervals.

When modify was attempting to edit this interval, it would fail since
synthetic intervals should not be written to the database unless the
database is being flattened and timewarrior believed the interval to be
modified was synthetic.

Closes #422

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Shaun Ruffell
3e5aa0d7ec Trivial: Fix indentation in getIntervalsById
Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2021-05-16 12:43:49 +02:00
Tomas Babej
e5870380a4
doc: Update copyright to 2021 2021-01-02 02:52:39 -05:00
Thomas Lauf
11877d3fff Restrict application of exclusions to range before now for open intervals
- Closes #370

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-08-18 18:58:05 +02:00
Thomas Lauf
07a6dfe313 Use functions is_started() and is_ended() instead of querying start/end directly
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-29 22:09:00 +02:00
Thomas Lauf
4637cd3d4e Do not manipulate filter in getTracked
- Filter shall be taken as is, not changed
- If there is a problem, the functions consuming the filter have to be adapted, not the filter

Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-06-29 22:07:35 +02:00
Thomas Lauf
9ae3ace109 Make getFilter(cli) a method of CLI 2020-05-10 21:44:30 +02:00
Thomas Lauf
ad58309159 Update Copyright
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-04-19 12:41:23 +02:00
Thomas Lauf
d73143b6cb remove unnecessary line breaks
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-04-14 10:11:39 +02:00
Shaun Ruffell
0b39a83a92 Filtering with tags should preserve the interval IDs.
This fixes the bug where, when filtering by tags, the interval IDs are not
preserved when not using any tags in the filter. Notice below how when
filtering with tag1, the two intervals are @4 and @5 instead of @1 and @5 like
they should be:

  $ timew summ :ids

  Wk Date       Day ID Tags    Start      End    Time   Total
  W9 2020-02-29 Sat @5 tag1 15:28:31 15:28:33 0:00:02
                    @4 tag2 15:28:33 15:28:35 0:00:02
                    @3 tag3 15:28:35 15:28:36 0:00:01
                    @2 tag4 15:28:36 15:28:48 0:00:12
                    @1 tag1 15:28:48        - 0:02:25 0:02:42

                                                      0:02:42

  $ timew summ tag1 :ids

  Wk Date       Day ID Tags    Start      End    Time   Total
  W9 2020-02-29 Sat @5 tag1 15:28:31 15:28:33 0:00:02
                    @4 tag1 15:28:48        - 0:02:28 0:02:30

                                                      0:02:30

This fixes a bug introduced in 86bb1465e8.

Closes issue #293 (thanks sskras)

Signed-off-by: Shaun Ruffell <sruffell@sruffell.net>
2020-03-06 16:10:19 +01:00
Thomas Lauf
0c1d7291e2 Use <..> instead of ".." for #include statements
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2020-03-03 07:57:33 +01:00
Thomas Lauf
35a38d628c Optimize handling of implicit latest interval
- If no id is given but active time tracking (i.e. open interval) is present
  then apply the command to the open interval
2020-02-01 23:49:56 +01:00
Shaun Ruffell
1abf6e9320 Database: firstLine -> getLatestEntry
firstLine is ambiguous (the first line that was added in time? The first line
that will be returned when iterating the database?)

See https://github.com/GothenburgBitFactory/timewarrior/pull/269#discussion_r367922757
2020-01-26 19:49:23 +01:00
Shaun Ruffell
2fcca6f949 trivial:coding-style: Add curly braces around blocks modified recently
timwarrior coding standard is for there to be curly braces around all code
blocks.

See https://github.com/GothenburgBitFactory/timewarrior/pull/269#discussion_r367937920
2020-01-26 19:49:23 +01:00
Shaun Ruffell
2df76a2ef0 Add helpers flattenDatabase and getIntervalsByIds
getIntervalsByIds will be used by commands that are loading complete database
currently when they really want a few intervals that the user specified by ID.

Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
610e78fede Remove getAllInclusions helper function
All locations in the code that was creating Intervals for all entries in
the database have been removed. This function can now be removed as
well.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
91e4da7a4c getUntracked helper function should not call getAllInclusions
The getUntracked, called as part of the `timew gaps` command, is
normally looking at a relatively recent interval. We do not want to take
the performance hit of loading the entire database into memory when
processing this command.

Related to issue #245
2020-01-17 17:48:57 +01:00
Shaun Ruffell
5dcf226d20 Database: Switch the natural order from newest inclusion to oldest
The inclusion database for the user always starts with the most recent
entry. It is now the same way in the code as well.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
623db0c8e4 Database: Remove Database::allLines()
The Database class itself can now be used in range-based for loops for iterating
over all the lines.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
bd1f7aef99 Remove unused outerRange
outerRange is no longer used, since the filter was simply started based on the
first line in the database now.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
9c0c27b55b getLatestInterval does not need to walk all the inclusions
This does not appear to be necessary anymore given that the database lines are
generated from intervals and are all well formed. Any open interval *should* be
at the end of the database.

Related to issue #245.
2020-01-17 17:48:57 +01:00
Shaun Ruffell
86bb1465e8 getTracked does not need to read in entire database
Related to issue #245.
2020-01-17 17:48:57 +01:00
Thomas Lauf
d64017a7a6 Update copyright dates
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-10-18 10:59:16 +02:00
Thomas Lauf
a672fd0647 Apply exclusions to open interval only within range within interval start and now
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
2019-04-11 10:42:08 +02:00
Thomas Lauf
72cfe7b4d8 Allow for closed intervals with start date in the future
- open intervals still have to start before now (move check to CmdStart)
- Closes #62
- Closes #142
2018-10-19 14:07:19 +02:00
Thomas Lauf
1a24c49507 Extract creation of intervals into IntervalFactory 2018-10-08 21:42:25 +02:00
Thomas Lauf
9dd106116c Let Interval inherit from Range
- Remove 1 level of indirection
- Remove public field Interval::range (instead use interval directly)
2018-09-19 06:32:56 +02:00
Thomas Lauf
9e1e604108 Rename Range::overlap to Range::overlaps 2018-09-18 21:06:33 +02:00
Janik Rabe
fef522c53d Fix getTracked() when last interval is empty 2018-09-18 21:06:05 +02:00
Janik Rabe
4325ffa136 Handle zero-width intervals correctly
Fixes #101
Fixes #165
Closes #164
2018-09-18 21:04:09 +02:00
Thomas Lauf
2c5812f7a3 Use the empty method to check for emptiness instead of comparing to an empty object 2018-05-10 20:57:22 +02:00
Simon Ruderich
2271bd9eea Use https:// link for opensource.org 2018-03-16 23:11:08 +01:00
Thomas Lauf
b2bc91402f TI-90: Make 'continue' accept a date range
- Do not set range end in command line, if not given
- Let commands set end of filter, if required
2017-12-05 16:47:13 +01:00
Paul Beckingham
d87a529d08 data: Added better error when an attempt is made to track a future interval 2017-05-28 09:43:37 -04:00
Paul Beckingham
60ce6cef25 Data: Using a single date instance, so that direct comparisons work 2017-05-28 09:33:28 -04:00
Paul Beckingham
754b08fc64 Data: Removed debugging code 2017-04-09 16:40:34 -04:00
Thomas Lauf
52853db6bd TI-68: Apply exclusions to open intervals only 2017-04-08 14:51:55 +02:00
Thomas Lauf
182cd5b0b4 TI-67: Assign ids to intervals after flattening but before filtering 2017-03-25 15:26:29 +01:00
Paul Beckingham
40e95ca65b data: getTracked now detects synthetic intervals 2017-03-19 15:37:07 -04:00
Paul Beckingham
34e43cdb55 data: Verify that filter date ranges are in the proper order 2016-07-09 08:06:31 -04:00
Paul Beckingham
61647e0f26 data: merge error skips one range 2016-07-04 13:08:52 -04:00
Paul Beckingham
1dc8eb7b4f data: getAllExclusions now merges results without data loss 2016-07-04 09:42:38 -04:00
Paul Beckingham
97756a871e data: Added merge function for merging ranges 2016-07-04 09:34:28 -04:00
Paul Beckingham
cd59f27b2f TI-9: Task spanning over whole day should show up as taking 24:00 instead of 23:59
- Thanks to Tomas Babej.
2016-07-03 10:10:07 -04:00
Paul Beckingham
803632793f data: Adds IDs to intervals even when there are no exclusions 2016-06-16 20:15:01 -04:00
Paul Beckingham
40cefe568b data: Sets ID metedata on load 2016-06-11 14:43:57 -04:00
Paul Beckingham
f8245c1552 data: Fixed separator detection
- Thanks to Sergey Trofimov
2016-06-07 06:55:32 -04:00
Paul Beckingham
41067c01ed TI-4: The 'timew' command considers only the last interval
- Thanks to Tomas Babej.
2016-06-06 23:23:28 -04:00