Skip to content

Commit

Permalink
Add notes/log messages for time entries (#1)
Browse files Browse the repository at this point in the history
* Resolve Issue jazzband#407: Migrate to arrow 1.0.0

- requirements.txt: specify arrow==1.00
- frames.py, fullmoon.py, watson.py: change "timestamp" to
  "int_timestamp"

* Resolve Issue jazzband#407: Migrate to arrow 1.0.0

- cli.py: change "date.tzinfo = tz.tzlocal()" to "date.replace(tzinfo=tz.tzlocal())"

* Update requirements.txt

This makes sense, especially given that arrow is already up to 1.0.2

Co-authored-by: Julien Maupetit <jmaupetit@users.noreply.github.com>

* Resolve Issue jazzband#407: Migrate to arrow 1.0.0

- watson.cli.py: use date = date.replace(tzinfo=tz.tzlocal())
  (date.replace does not modify the existing object)

* Resolve Issue jazzband#407: Migrate to arrow 1.0.0

Update unit test cases:

- tests/test_cli.py: replace arrow.arrow.datetime with arrow.arrow.dt_datetime
- tests/test_watson.py: replace .timestamp with .int_timestamp

* Resolve Issue jazzband#407: Migrate to arrow 1.0.0

- .travis.yml: remove python 3.5
- setup.py: require python >= 3.6
- CHANGELOG.md: mention arrow upgrade and drop of python 3.5 support

* Update watson.zsh-completion

fix: autocompletion won't work with zsh 5.8

* Use TZ environment variable to set the timezone (jazzband#411)

Watson did not have a way to set the timezone, other than what the system used.
In UNIX you can set the TZ variable to represent the timezone you want your
programs to respect.

* Bump release to 2.0.0

Added:

- The `log` command output can now be filtered to exclude projects and
  tags via `--ignore-project` and `--ignore-tag` (jazzband#395)
- Python 3.8 support (jazzband#402)
- Python 3.9 support (jazzband#402)
- Support for the TZ environment variable to specify the local time zone
  (jazzband#391)

Changed:

- Upgrade to major arrow release 1.0.0 (jazzband#407)

Fixed:

- Zsh completion (jazzband#379)

Removed:

- Python 2.7 support (jazzband#305).
- Python 3.5 support (jazzband#407).

* Fix year in 2.0.0 release

Believe it or not its 2021!

* Gracefully handle empty stop time (jazzband#418)

Recent arrow library update broke the current frame edition.

* Bump release to 2.0.1

Fixed:

- Ability to `edit` the current frame (jazzband#418)

* Add 'notes' field to frames.

This is a large commit that adds the following:

1. Syntax: `watson stop --notes "some additional information"`.
2. Print only non-empty notes in log.
3. Always pass id to `new_frame` so that the length of array with/without
   notes doesn't cause ambiguity.
4. Print a warning message and the existing note if overwriting a note.
5. Print notes in report.

Primary work here was done by the following people:

Co-authored-by: Tristan Pratt <prat0088@gmail.com>
Co-authored-by: Joel Ostblom <joelostblom@users.noreply.github.com>

* notes: Print notes in `watson log`.

* notes: Fix tests.

* Set requirements for click >= 8.0 and rename autocompletion parameter to shell_complete. Remove 'multiple' paramater on reporting option

Co-authored-by: Jason Youzwak <jyouzwak@perspectalabs.com>
Co-authored-by: veganjay <veganjay@gmail.com>
Co-authored-by: Julien Maupetit <jmaupetit@users.noreply.github.com>
Co-authored-by: Nikolay Shkrylev <snnwolf@users.noreply.github.com>
Co-authored-by: Eddie Ash <cazador481@users.noreply.github.com>
Co-authored-by: Julien Maupetit <julien@maupetit.net>
Co-authored-by: Matthew Barry <komputerwiz.matt@gmail.com>
Co-authored-by: Rohitt Vashishtha <aero31aero@gmail.com>
Co-authored-by: Tristan Pratt <prat0088@gmail.com>
Co-authored-by: Joel Ostblom <joelostblom@users.noreply.github.com>
  • Loading branch information
11 people authored Apr 17, 2022
1 parent 560e962 commit f9e6172
Show file tree
Hide file tree
Showing 16 changed files with 446 additions and 135 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ matrix:
os: linux
dist: xenial
env: TOXENV=flake8
- python: 3.5
os: linux
dist: trusty
env: TOXENV=py35
- python: 3.6
os: linux
dist: trusty
Expand Down
25 changes: 23 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,34 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.1] - 2021-05-10

### Fixed

- Ability to `edit` the current frame (#418)

## [2.0.0] - 2021-03-19

### Added

- The `log` command output can now be filtered to exclude projects and tags via `--ignore-project` and `--ignore-tag` (#395)
- The `log` command output can now be filtered to exclude projects and tags via
`--ignore-project` and `--ignore-tag` (#395)
- Python 3.8 support (#402)
- Python 3.9 support (#402)
- Support for the TZ environment variable to specify the local time zone (#391)

### Changed

- Upgrade to major arrow release 1.0.0 (#407)

### Fixed

- Zsh completion (#379)

### Removed

- Python 2.7 support (#305).
- Python 3.5 support (#407).

## [1.10.0] - 2020-07-03

Expand Down Expand Up @@ -260,7 +279,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

First stable public release 🎉

[unreleased]: https://github.com/tailordev/watson/compare/1.10.0...HEAD
[unreleased]: https://github.com/tailordev/watson/compare/2.0.1...HEAD
[2.0.1]: https://github.com/tailordev/watson/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/tailordev/watson/compare/1.10.0...2.0.0
[1.10.0]: https://github.com/tailordev/watson/compare/1.9.0...1.10.0
[1.9.0]: https://github.com/tailordev/watson/compare/1.8.0...1.9.0
[1.8.0]: https://github.com/tailordev/watson/compare/1.7.0...1.8.0
Expand Down
31 changes: 31 additions & 0 deletions docs/about/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [2.0.1] - 2021-05-10

### Fixed

- Ability to `edit` the current frame (#418)

## [2.0.0] - 2021-03-19

### Added

- The `log` command output can now be filtered to exclude projects and tags via
`--ignore-project` and `--ignore-tag` (#395)
- Python 3.8 support (#402)
- Python 3.9 support (#402)
- Support for the TZ environment variable to specify the local time zone (#391)

### Changed

- Upgrade to major arrow release 1.0.0 (#407)

### Fixed

- Zsh completion (#379)

### Removed

- Python 2.7 support (#305).
- Python 3.5 support (#407).

## [1.10.0] - 2020-07-03

### Added
Expand Down Expand Up @@ -247,6 +276,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

First stable public release 🎉

[2.0.1]: https://github.com/tailordev/watson/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/tailordev/watson/compare/1.10.0...2.0.0
[1.10.0]: https://github.com/tailordev/watson/compare/1.9.0...1.10.0
[1.9.0]: https://github.com/tailordev/watson/compare/1.8.0...1.9.0
[1.8.0]: https://github.com/tailordev/watson/compare/1.7.0...1.8.0
Expand Down
8 changes: 7 additions & 1 deletion docs/user-guide/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -705,17 +705,23 @@ If `--at` option is given, the provided stopping time is used. The
specified time must be after the beginning of the to-be-ended frame and must
not be in the future.

Example:
You can optionally pass a log message to be saved with the frame via
the ``-n/--note`` option.

Example:

$ watson stop --at 13:37
Stopping project apollo11, started an hour ago and stopped 30 minutes ago. (id: e9ccd52) # noqa: E501
$ watson stop -n "Done some thinking"
Stopping project apollo11, started a minute ago. (id: e7ccd52)
Log message: Done some thinking

### Options

Flag | Help
-----|-----
`--at DATETIME` | Stop frame at this time. Must be in (YYYY-MM-DDT)?HH:MM(:SS)? format.
`-n, --note TEXT` | Save given log message with the project frame.
`--help` | Show this message and exit.

## `sync`
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
arrow>=0.15.6
click>=7.0
arrow>=1.0.0
click>=8.0
click-didyoumean
colorama; sys_platform == "win32"
requests
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def parse_requirements(requirements, ignore=('setuptools',)):
license='MIT',
long_description=readme,
install_requires=parse_requirements('requirements.txt'),
python_requires='>=3.5',
python_requires='>=3.6',
tests_require=parse_requirements('requirements-dev.txt'),
entry_points={
'console_scripts': [
Expand Down
16 changes: 8 additions & 8 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from itertools import combinations
from datetime import datetime, timedelta

from dateutil.tz import tzlocal
import pytest

from watson import cli
from watson.cli import local_tz_info


# Not all ISO-8601 compliant strings are recognized by arrow.get(str)
Expand Down Expand Up @@ -172,14 +172,14 @@ def test_report_invalid_date(runner, watson, test_dt):

@pytest.mark.parametrize('at_dt', VALID_TIMES_DATA)
def test_stop_valid_time(runner, watson, mocker, at_dt):
mocker.patch('arrow.arrow.datetime', wraps=datetime)
start_dt = datetime(2019, 4, 10, 14, 0, 0, tzinfo=tzlocal())
arrow.arrow.datetime.now.return_value = start_dt
mocker.patch('arrow.arrow.dt_datetime', wraps=datetime)
start_dt = datetime(2019, 4, 10, 14, 0, 0, tzinfo=local_tz_info())
arrow.arrow.dt_datetime.now.return_value = start_dt
result = runner.invoke(cli.start, ['a-project'], obj=watson)
assert result.exit_code == 0
# Simulate one hour has elapsed, so that 'at_dt' is older than now()
# but newer than the start date.
arrow.arrow.datetime.now.return_value = (start_dt + timedelta(hours=1))
arrow.arrow.dt_datetime.now.return_value = (start_dt + timedelta(hours=1))
result = runner.invoke(cli.stop, ['--at', at_dt], obj=watson)
assert result.exit_code == 0

Expand All @@ -189,8 +189,8 @@ def test_stop_valid_time(runner, watson, mocker, at_dt):
@pytest.mark.parametrize('at_dt', VALID_TIMES_DATA)
def test_start_valid_time(runner, watson, mocker, at_dt):
# Simulate a start date so that 'at_dt' is older than now().
mocker.patch('arrow.arrow.datetime', wraps=datetime)
start_dt = datetime(2019, 4, 10, 14, 0, 0, tzinfo=tzlocal())
arrow.arrow.datetime.now.return_value = (start_dt + timedelta(hours=1))
mocker.patch('arrow.arrow.dt_datetime', wraps=datetime)
start_dt = datetime(2019, 4, 10, 14, 0, 0, tzinfo=local_tz_info())
arrow.arrow.dt_datetime.now.return_value = (start_dt + timedelta(hours=1))
result = runner.invoke(cli.start, ['a-project', '--at', at_dt], obj=watson)
assert result.exit_code == 0
4 changes: 2 additions & 2 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def test_frames_to_csv(watson):
result = frames_to_csv(watson.frames)

read_csv = list(csv.reader(StringIO(result)))
header = ['id', 'start', 'stop', 'project', 'tags']
header = ['id', 'start', 'stop', 'project', 'tags', 'note']
assert len(read_csv) == 2
assert read_csv[0] == header
assert read_csv[1][3] == 'foo'
Expand All @@ -319,7 +319,7 @@ def test_frames_to_json(watson):

result = json.loads(frames_to_json(watson.frames))

keys = {'id', 'start', 'stop', 'project', 'tags'}
keys = {'id', 'start', 'stop', 'project', 'tags', 'note'}
assert len(result) == 1
assert set(result[0].keys()) == keys
assert result[0]['project'] == 'foo'
Expand Down
Loading

0 comments on commit f9e6172

Please sign in to comment.