Giter Club home page Giter Club logo

hamster-lib's Introduction

hamster-lib

image

image

image

Documentation Status

Requirements Status

(A badges refer to master)

A library for common timetracking functionality.

hamster-lib aims to be a replacement for projecthamster backend library. While we are not able to function as a straight forward drop-in replacement we try very hard to stay as compatible as possible. As a consequence clients are able to switch to hamster-lib merely by changing some basic calls. Most of the semantics and return values will be as before.

This itself points to a major architectural shift in the way hamster-lib approaches timetracking. We are firm believers in do one thing, and do it well. The tried and tested unix toolbox principle. As such we focus on providing useful backend functionality and helper methods so clients (dbus interfaces, CLIs or graphical UIs) can build upon a solid and consistent base and focus on their specific requirements.

Features

  • Full python >=2.7 and >=3.4 compatibility
  • Full unicode support
  • >= 95% test coverage
  • Extensive documentation
  • Focus on clean, maintainable code.
  • Free software: GPL3
  • All you need for production, test or dev environments comes out of the box with regular python tools.

First Steps

  • Build dev environment: make develop
  • Build the documentation locally: make docs
  • Run just the tests: make test
  • Run entire test suite including linters and coverage: make test-all

Additional Resources

News: Version 0.13.0

This release features only few public functional changes:

  1. Raw fact parsing has been moved to a helper method. This should make it easier for clients to parse raw fact strings even if they do not qualify as valid Fact instances.
  2. Facts now provide a serialied_string method that encodes all relevant data.
  3. We now ship config helpers that provide a baseline config that can easily be extended instead of each client having to implement this all over again.

For a more detailed overview about what new as well as a list of all the smaller improvements, please refer to the changelog.

Happy tracking; Eric.

Todo

This early release is mainly meant as a rough proof-of-concept at this stage. It showcases our API as well as our general design decisions. As such there are a few functionalities/details of the original projecthamster backend that we wish to allow for, but are not provided so far. These are:

  • Autocomplete related methods
  • Trophies (The jury is still out on if and how we want to support those.)
  • Migrations from old databases.

Incompatibilities

Despite our efforts to stay backwards compatible we did deliberately break the way Facts without end dates are handled. We think allowing for them in any persistent backend creates a data consistency nightmare and so far there seems no conceivable use case for it, let alone an obvious semantic. What we do allow for is one ongoing fact. That is a fact that has a start, but no end date. For details, please refer to the documentation.

Credits

Tools used in rendering this package:

hamster-lib's People

Contributors

elbenfreund avatar felixschwarz avatar jtojnar avatar requires avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hamster-lib's Issues

Add 'stop' command

Add a command to stop the current 'ongoing fact'. That is to add an end date to a fact.

'parse_time_info' fallback for end time should be corrected.

The original implementation falls back to datetime.time() if no end time is given.
That however translates to 00:00. Legacy hamster-cli help itself however claims it would default to 23:59.
Our original implementation stuck to the fauli behaviour in order to stay compatible.
Our new API however should correct that behaviour.

Also: it may be more sensible to respect configs day-end setting here instead of 23:59.

'parse_raw_fact' should utilise improved time parsing method

Due to legacy hamster-cli our Controler provides a dedicated time_range_parsing function (#25) that features a more flexible time pattern. We should adjust our parse_raw_fact method to make use of this extended flexibility as well.

In order to stay API compatible this should only happen once we are willing to break backwards compatibility.

Add 'list activities' command

A a way to list all activities present in the backend.

  • Activities means activities in the way our our librarsy, that is an name/category conbination.
  • Activities should be retuned as an ordered list (by category).

Refactor parse_time_info method

By mimicing the original implementation our own version tries to do far to much.
Right now we do not only parse the info-string but also handle fallbacks and default logic.
This should be done seperatly.

One of the current downsides, just like in the legacy code, is that defaults are handled in various places.
Instead this method should just parse the string and return the decomposed instances.
We can then have a seperate method that evaluates those and may assign defaults/fallbacks. If this is to happen in the frontend or on the client level remains to be seen.

Also, it seems sensible to move this function to a helper module.

Add 'start' command

start in our initial implementation unifies two faculties:

  1. Add a new fact. That is add a comlete fact with full start/end informaion
  2. Start a "temporary fact" that is an incomplete fact, not stored in the backend until complete.

Create helper method that applies default values to incomplete timeframe

Timeframes as returned by hamsterlib.helpers.parse_time_info may miss some of their attribues and as a consequencec not provide a comple referenceframe.

This helper function applies our default fallback/autocomplete strategy in one central place and returns a complete (start, end) tuple of datetime objects.

Remove documentation of legacy behaviour from docstrings

In the past we droped information about legacy hamsters 'API' and expected behaviour right into our codebase. With this release we should clean out those.
If we feel the information is still relevant it should be move into the regular documentation.

Add dedicated time parsing method

Right now, we use the original libs general spec to disect time information when parsing a raw_fact.

The legacy client code however allows much more elaborate time specifications as well as providing a nice parsing function.

In order to avoid reimplementing this in every client, our Controler should provide a parse_time_info method that takes care of that.

Note: This new method may also be utilized by our parse_raw_fact method at a later point.

Re-Examine all [FIXME] comments

Throughout initial development we placed several # [FIXME] Blocks to indicate issues that we need to have a look at later on, once the initial dust has settled.
These can only be short term solutions. We need to go through them and either turn them into proper issues or remove them if they have been rendered obsolete by now.

Account for original Fact.date concept

The original implemenation has a rather convoluted concept of a Fact.date and how this relates to __get_facts. Also see legacy information.

The way the original implementation does this is by fetching all facts deemed relevant and assign them date and delta. this is no option for a pure lookup method. We clearly can not look facts up by those properties and in light of an unknown amount of return values this needs to be handled somewhere else. This is where our Hamster.Fact()-properties shine. However, that also means that we can no look up facts by date!

Our first incarnations simply this significantly. A fact.date is the date of a facts startdate.
At some point we should investigate if/how we refactor this to satisfy original API requirements.

Contemplate 'start/save ongoing fact' behavior

Right now, facts.save() will be very accomodating and call _start_tmp_fact if it recieves a fact without end. This makes adding ongoing facts very transparent.
Is this bug or feature? The alternative would be to return an error, suggesting to client to use a dedicated public start_tmp_fat method.

Add 'get ongoing fact'

store.facts needs a way to retrieve the current ongoing fact. Should return KeyError if ther is none.

get_all() facts respects search terms

Besides filtering by timeframe, we also want to allow to just match certain terms.

According to this we need to match it against the following:

  • fact.activity.name
  • fact.category.name
  • fact.tag.name

Introduce the notion of an 'ongoing fact'

Originaly we wanted to keep any notion of 'ongoing facts' strictly on in the frontend/client-code.

This however, causes problems, for example with representing a Fact missing attributes at a given point.

Whilst we stick to our decission and will not store any ongoing facts our hamsterli object itself will have a ongoing property that allows for easy checks.

Add 'export' command

Add a command to to export existing facts to one of various files.

supported file formats:

  • html
  • tsv
  • ical
  • xml

uniqe names vs casesensetivity

Right now, category names are case sensitive and unique. This in itself is not a problem.
However, if we later come to decide that search is to be case insensetive, we may up with several results for one search string despite the uniqueness constraint.

We will have to decide if this is desired behavior and we deal with multiple results or if it is preferable to enforce "case insensitive uniqueness" and avoid such subtleties.

Provide reporting capabilities

legacy hamster provides a basic reports module. In order to stay compatible we should adjust it as far as feasable and incorporate it into hamsterlib.

Refactor `get_all()` activities

Our current method does not match the legacy functionality.
Although some bizzare unused function in hamster-cli does specify categories this is actually not relevant for us.
Instead this method is to return:

  • list of all activities
  • optionaly searched against activity.name (insensitive)
  • ordered by activity name

Add 'search' command

Users can search existing Facts against a string within an optional timeframe.

  • start/end time is optional
  • string matches against a facts activity name

Add a 'search' command.

Add a command to list facts matching certain criteria ..

Note: How is this different from list command.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.