fnogatz / clocker

Command-line tool to track project hours
Other
420 stars 31 forks source link

clocker report bug for overnight entries #39

Closed fnogatz closed 5 years ago

fnogatz commented 6 years ago

When an entry lasts longer than midnight, clocker report returns wrong results.

Steps to reproduce:

> mkdir /tmp/clocker
> clocker -d /tmp/clocker start
> clocker -d /tmp/clocker set start 'yesterday 22:00'
> clocker -d /tmp/clocker stop
> clocker -d /tmp/clocker set end '06:00'
> clocker -d /tmp/clocker list
1532376000  2018-07-23  [ 22:00:00 - 06:00:00 ]  (08:00:00)
> clocker -d /tmp/clocker report
Report for 24 July 2018:

total: 00:00:00

There are 6 hours missing :)

@BeniRupp, any chance you could provide a fix for this?

BeniRupp commented 6 years ago

You are right! Thanks for reporting this bug! 👍

The 6 hours are not really missing, because if you run clocker report --reportDay 2018-07-23 you will get 8 hours as total workload. But I agree, that is not what we would expect.

So I will have a look on the total workload calculation to provide a more appropriate solution.

BeniRupp commented 5 years ago

Sorry for the late reply. 🙈 But I've tried to fix that issue with some colleagues at the Hackergarten this week. (Thanks to @codestoe, @wandertaker, @konqi and Robin)

This is just a bug fix. For further report functionallity (weeks, month, ...) we should re-think the data saved in the database. One idea is to split up a worklog when define the end of it in a way that we have one entry per day with the correct amount of time spent on this item. So we can query the data by the start date again:

So 2019-02-02 22:00:00 - 2019-02-03 06:00:00 is saved in the database as:

fnogatz commented 5 years ago

Thank you for the input. I moved some parts of the discussion into a new issue #43.