imag/lib/domain/libimagtimetrack
Matthias Beyer d4872f6da3 Optimize the Store::entries() interface
The previous iterator was implemented to simply fetch _all_ pathes from
the filesystem, no matter what.

With this implementation, this changes. The iterator now has
functionality to optimize the iteration, if only a subdirectory of the
store is required, for example `$STORE/foo`.

This is done via functionality where the underlying iterator gets
altered.

First of all, the interface was changed to return a `Entries` object,
which itself only covers the libimagstore-internal `PathIterator` type.
This type was changed so that the backend implementation provides an
"PathIterBuilder`, which builds the actual iterator object for the
`PathIterator` type.

The intermediate `StoreIdConstructingIterator` was merged into
`PathIterator` for simplicity.

The `Entries` type got functionality similar to the
`StoreIdIteratorWithStore` type for easier transition to the new API.
This should probably be removed at a later point, though.

As the `walkdir::WalkDir` type is not as nice as it could be, iterators
for two collections in the store could be built like this (untested):

    store
        .entries()?
        .in_collection("foo")
        .chain(store.entries()?.in_collection("bar"))

Functionality to exclude subdirectories is not possible with the current
`walkdir::WalkDir` implementation and has to be done during iteration,
with filtering (as usual).

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2018-09-27 12:19:18 +02:00
..
src Optimize the Store::entries() interface 2018-09-27 12:19:18 +02:00
Cargo.toml Update version string: 0.8.0 -> 0.9.0 2018-05-09 11:39:33 +02:00
README.md libimagentrytimetrack -> libimagtimetrack 2017-08-27 18:23:47 +02:00

libimagtimetrack

A library for tracking time events in the imag store.

Store format

Events are stored with a store id like this:

/timetrack/<insert-date-year>/<insert-date-month>/<insert-date-day>/<insert-date-time>-<tag>.ext

Timetrackings contain

  • a comment (optional, free text)
  • a start date
  • an end date
  • a tag

by default and might be extended with more header fields as one likes.

The header of a timetrack "work" entry looks like this:

[event]
tag = "work"
start = "2017-01-02T03:04:05"
end = "2017-01-02T06:07:08"

Normal tags (as in libimagentrytag) are explicitely not used for tagging, so the user has the possibility to use normal tags on these entries as well.

The tag field is of type string, as for one tag, one entry is created. This way, one can track overlapping tags, as in:

imag timetrack start foo
imag timetrack start bar
imag timetrack stop foo
imag timetrack start baz
imag timetrack stop bar
imag timetrack stop baz

The end field is, of course, only set if the event already ended.

Library functionality

The library uses the libimagentrydatetime::datepath::DatePathBuilder for building StoreId objects.

The library offers two central traits:

  • TimeTrackStore, which extends a Store object with functionality to create FileLockEntry objects with a certain setting that is used for time-tracking, and
  • TimeTracking, which extends Entry with helper functions to query the entry-metadata that is used for the time tracking functionality

The library does not provide functionality to implement imag-timetrack or so, as the core functionality is already given and the commandline application can implement the missing bits in few lines of code.

Aggregating functionality might be provided at a later point in time.