Skip to content

Commit

Permalink
feat: Add summary reporting for clients & projects (#4)
Browse files Browse the repository at this point in the history
* feat: base calculations for summary reports

Includes some of the tests, none of the API calls yet.

* feat: added CLI support for including summary

Also refactored API calls out into seperate file

* fix: now sorts items

* docs: updated readme to reflect one less line to hide

* docs: readme updates
  • Loading branch information
dhutchison committed Jul 19, 2021
1 parent 02dcf4f commit 8e58c38
Show file tree
Hide file tree
Showing 12 changed files with 2,621 additions and 2,714 deletions.
110 changes: 49 additions & 61 deletions README.md
Expand Up @@ -30,6 +30,7 @@ Options:
-d, --day <date> day to report on (in yyyy-MM-dd format). If a date is not supplied
then this will default to today. (default: "2020-09-21")
-w, --week If specified, interpret the day as the start of a week.
--include-summary If specified, include client/project summary detail
-h, --help display help for command
```

Expand All @@ -50,66 +51,56 @@ If the program is called with a `DOT_ENV_CONFIG` environment variable set, then
An example of running this for a single day:
```
$ npx @devwithimagination/toggl-summary-cli -d 2020-09-18
Report loaded, total booked time: 02:49:13
Unbooked time since last entry: 00:22:04
Unbooked time since last entry: 00:11:02
Unbooked time since last entry: 00:15:05
==== Totals for 2020-09-18 to 2020-09-18 ====
Counted booked time: 02:49:11
Counted unbooked time: 00:54:20
Counted break time: 00:00:00
Counted total time: 03:43:31
# Totals for 2020-09-18 to 2020-09-18
* Booked time: 02:49:11
* Unbooked time: 00:54:20
* Break time: 00:00:00
* Total time (booked + unbooked): 03:43:31
```

An example of running this for a single day, including summary information:
```
$ npx @devwithimagination/toggl-summary-cli -d 2020-09-18 --include-summary
# Totals for 2020-09-18 to 2020-09-18
* Booked time: 02:49:11
* Unbooked time: 00:54:20
* Break time: 00:00:00
* Total time (booked + unbooked): 03:43:31
# Summary
* Client-1: 31.74% (01:10:57)
* UI: 55.39% (00:39:18)
* API: 44.61% (00:31:39)
* Unknown Client/Project: 24.78% (00:55:23)
* Unknown Client/Project: 100.00% (00:55:23)
* Unbooked Time: 24.31% (00:54:20)
```

Running for a single day, using a configuration file in an alternative location:
```
$ DOT_ENV_CONFIG=~/.toggl-summary-cli.env npx @devwithimagination/toggl-summary-cli -d 2020-09-18
Report loaded, total booked time: 02:49:13
Unbooked time since last entry: 00:22:04
Unbooked time since last entry: 00:11:02
Unbooked time since last entry: 00:15:05
==== Totals for 2020-09-18 to 2020-09-18 ====
Counted booked time: 02:49:11
Counted unbooked time: 00:54:20
Counted break time: 00:00:00
Counted total time: 03:43:31
# Totals for 2020-09-18 to 2020-09-18
* Booked time: 02:49:11
* Unbooked time: 00:54:20
* Break time: 00:00:00
* Total time (booked + unbooked): 03:43:31
```

Running for a week:
```
$ npx @devwithimagination/toggl-summary-cli -d 2020-09-14 -w
Report loaded, total booked time: 34:26:11
Unbooked time since last entry: 00:15:26
Unbooked time since last entry: 00:14:40
Unbooked time since last entry: 00:15:05
Break time! 00:55:40
Unbooked time since last entry: 00:08:04
Unbooked time since last entry: 00:45:49
Unbooked time since last entry: 00:07:16
Unbooked time since last entry: 00:10:04
Unbooked time since last entry: 00:29:01
Unbooked time since last entry: 00:07:33
Break time! 00:52:03
Unbooked time since last entry: 00:25:20
Unbooked time since last entry: 00:30:34
Break time! 00:07:51
Unbooked time since last entry: 00:22:04
Unbooked time since last entry: 00:11:02
Unbooked time since last entry: 00:15:05
Unbooked time since last entry: 00:06:41
Unbooked time since last entry: 00:15:06
Unbooked time since last entry: 00:13:41
Unbooked time since last entry: 00:19:29
Unbooked time since last entry: 00:07:34
Break time! 00:24:27
Break time! 00:56:54
Unbooked time since last entry: 00:18:09
Unbooked time since last entry: 00:06:47
==== Totals for 2020-09-14 to 2020-09-21 ====
Counted booked time: 21:14:34
Counted unbooked time: 05:59:31
Counted break time: 03:16:55
Counted total time: 27:14:05
# Totals for 2020-09-14 to 2020-09-20
* Booked time: 28:21:26
* Unbooked time: 07:20:12
* Break time: 04:01:59
* Total time (booked + unbooked): 35:41:38
```

When running this from a locally checked out project, you need to pass `--` to stop `ts-node` interpreting the arguments as its own.
Expand All @@ -120,15 +111,12 @@ $ npm run cli -- -d 2020-09-18
> @devwithimagination/toggl-summary-cli@0.1.0-alpha.1 cli /Users/david/Development/Projects/toggl-summary-cli
> ts-node ./src/cli.ts "-d" "2020-09-18"
Report loaded, total booked time: 02:49:13
Unbooked time since last entry: 00:22:04
Unbooked time since last entry: 00:11:02
Unbooked time since last entry: 00:15:05
==== Totals for 2020-09-18 to 2020-09-18 ====
Counted booked time: 02:49:11
Counted unbooked time: 00:54:20
Counted break time: 00:00:00
Counted total time: 03:43:31
# Totals for 2020-09-18 to 2020-09-18
* Booked time: 02:49:11
* Unbooked time: 00:54:20
* Break time: 00:00:00
* Total time (booked + unbooked): 03:43:31
```

### Advanced Usage - To create a Day One Entry
Expand All @@ -137,12 +125,12 @@ I use [Day One](https://dayoneapp.com) as my journaling application of choice. T

To create a daily entry, for the current day, I run:
```
$ dayone2 --tags work -- new $'End of Day Work Summary\n\n' "$(DOT_ENV_CONFIG=~/.toggl-summary-cli.env npx @devwithimagination/toggl-summary-cli | tail -n +2)"
$ dayone2 --tags work -- new $'End of Day Work Summary\n\n' "$(DOT_ENV_CONFIG=~/.toggl-summary-cli.env npx @devwithimagination/toggl-summary-cli )"
```

To create a weekly entry, for the current week, I run:
```
$ dayone2 --tags work -- new $'End of Week Work Summary\n\n' "$(DOT_ENV_CONFIG=~/.toggl-summary-cli.env npx @devwithimagination/toggl-summary-cli -d $(date -v -Mon +%Y-%m-%d) -w | tail -n +2)"
$ dayone2 --tags work -- new $'End of Week Work Summary\n\n' "$(DOT_ENV_CONFIG=~/.toggl-summary-cli.env npx @devwithimagination/toggl-summary-cli -d $(date -v -Mon +%Y-%m-%d) -w )"
```

## Testing
Expand Down

0 comments on commit 8e58c38

Please sign in to comment.