-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add date range for utt report #9
Conversation
…the given date range
I added |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank your for this pull request! I added two comments.
Once the current activity issue is fixed, I'll merge your pull request and make a new release.
utt/cmd_report.py
Outdated
activity = Activity(entry_pair[0].datetime, entry_pair[1]).clip( | ||
start_datetime, end_datetime) | ||
if (activity.duration > datetime.timedelta() and | ||
activity.name.name != HELLO): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer if we don't rely on "hello"
. The name of the first entry in a day can be anything. By convention it is "hello"
since most users are probably using utt hello
. However, there is a slight probability that explicitly checking for "hello"
is a breaking change for a few users.
This doesn't need to be addressed, but if you find a way to avoid this breaking change that would be ideal.
utt/cmd_report.py
Outdated
today = now.date() | ||
if report_date == today and entries and entries[-1].datetime < now and \ | ||
not disable_current_activity: | ||
if entries and entries[-1].datetime < now and not disable_current_activity: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The current activity should only be added if the user looks at today's report. By removing report_date == today
the current activity is now added even when the user looks at, say, yesterday's report. This creates a bogus current activity:
$ cat /root/.local/share/utt/utt.log
2018-08-18 22:00 hello
2018-08-18 22:10 foo
$ utt --now "2018-08-19 23:00" report 2018-08-18
----------------------- Saturday, Aug 18, 2018 (week 33) -----------------------
Working Time: 1 day, 1h00 (0h10 + 1 day, 0h50) [25h00]
Break Time: 0h00 [0h00]
----------------------------------- Projects -----------------------------------
(1 day, 1h00) : -- Current Activity --, foo
---------------------------------- Activities ----------------------------------
(1 day, 0h50) : -- Current Activity --
(0h10) : foo
----------------------------------- Details ------------------------------------
(0h10) 22:00-22:10 foo
(1 day, 0h50) 22:10-23:00 -- Current Activity --
Thank you @larose for reviewing and for pointing out the breaking changes. What I just pushed are changes to ignore activities that span over the mid-night, and this should address both the "alternative hello" usage and the bogus current activity when logs are organized daily. However I should point out that this assumption on people not working overnight is not true for me and for my colleagues! One of my colleagues worked around by adding an activity close to midnight, i.e. at 23:59. Please can I add an option to include overnight activities in the report? I can do that in a separate PR or this one, if you'd prefer. |
utt/cmd_report.py
Outdated
activity = Activity(prev_entry.datetime, next_entry) | ||
# For preserving existing behaviour, skip activities spanning | ||
# over midnights | ||
if prev_entry.datetime.date() != next_entry.datetime.date(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I probably should check if the activity is already ignored via its type.
Add missing trailing newline in the data file for stdout
I added a few more commits to handle warnings about the overnight activities being ignored... it would seem wrong to me not to warn about them as they are actively being filtered. |
I tried you latest code and I still have an unwanted current activity (that is shown as an ignored overnight activity):
I think we can support overnight activity when using
and we remove the filtering of overnight activities. Here are the high-level requirement for current activity:
I realize those requirements should be tests and I'll try to add them. |
I added a commit with the test: 4b87d0a The commit is on top of yours. You can add it to you PR. |
Thank you for testing and clarifying the requirements for the current activity. If I understand correctly, the And regarding your previous comment:
With your suggested changes where overnight activities are not filtered (yay!), users who do not use I will try to work on this later tonight. Thanks again! |
There seems to be a bug. Here is the output of utt when I don't have anything today, just entries yesterday:
If I don't have anything today. I expect to see nothing. Not starting the clock automatically at midnight. After all the effort you made (plus this PR: #6), I feel that supporting overnight activity in the Maybe we should add a new argument |
Thanks @larose for giving this another look! I am really grateful. I will be happy to implement the workaround for adding the 23:59 and midnight entries, if there is really no better way to incorporate overnight activities without breaking the application for others. But first of all I hope you could explain to me why the new behaviour you posted above is a bug, because I am not sure it is. Just to confirm that I understood the scenario: You have a current activity spanning from yesterday (sometime) to now, i.e. you have not added any entry (not even hello) since that sometime yesterday. You are fetching the report for today only and you expect the report for today to be empty. Why is an empty report expected? Is that because that the current activity does not exist if one never adds any entry for today? Why is that? If I could understand this, maybe there is a better way to fix it without the workaround. A bit more on why I think the new behaviour is expected: Say I have been travelling since yesterday 9PM, and it is 11AM now and I am still travelling (forget about timezone for now). If I finish my travel, and type From the point of view of a user who never works overnight, this new "absurd" current activity indicates that they have forgotten to say hello to utt. If we should workaround with the 23:59/midnight entries, then I would probably want to make that workaround automatic as it is likely that I, as a user, will forget to add the |
You did convince me that this is the right behavior. Hopefully there won't be too many complaints :) I just released version 1.8 with your changes. Thank you for your contribution! |
Thank you very much @larose! |
This pull request adds
--from
and--to
to theutt report
command for aggregating activities in a given date range. This provides the basic requirement for #4Example:
With date range support, shortcuts such as
utt report week
orutt report January
can be implemented later.I too have use cases where I needed to get a weekly or monthly report.
The "Details" section is skipped as I assume it would be too long, esp for yearly report?