dominikbraun / timetrace

A simple CLI for tracking your working time.
Apache License 2.0
685 stars 76 forks source link

Ideas for `timetrace report` #88

Open dominikbraun opened 3 years ago

dominikbraun commented 3 years ago

I'm planning for a timetrace report command which should generate a report of the tracked time. This issue is a small idea collection for the new command.

@FelixTheodor, @rocar, @rknizzle, @aaronsheah, @joshuaherrera, @Gealber, @KonstantinGasser, @adzo261, @obnoxiousnerd, @aligator and @nrobinson2000 should feel free to add their suggestions here!

dominikbraun commented 3 years ago
dominikbraun commented 3 years ago
KonstantinGasser commented 3 years ago

Does the report needs to follow a specific structure in order to be import it into some other software? If so, providing CSV output might also be useful in addition to JSON, right? timetrace report where the default could be JSON and report can have a csv flag?

dominikbraun commented 3 years ago

I'd suggest that timetrace report prints a table as usual, and a --output option accepts json and csv as values.

KonstantinGasser commented 3 years ago

Ok I see. If timetrace start project has not been stopped yet should this ongoing period be ignored in the report or be included? I guess another question would be whether the user defines the output directorty/file or if the report.json/csv will be stored in a ~/.timetrace directory?

dominikbraun commented 3 years ago

If timetrace start project has not been stopped yet should this ongoing period be ignored in the report or be included? I guess another question would be whether the user defines the output directorty/file or if the report.json/csv will be stored in a ~/.timetrace directory?

Good questions - especially the latter one should be discussed.

KonstantinGasser commented 3 years ago

Since timetrace provides an interface to its config one other option could be to let the user change the lets say report-dir config field to whatever directory. The default could be in for example the ~/.timetrace/reports directory?

retronav commented 3 years ago

If timetrace start project has not been stopped yet should this ongoing period be ignored in the report or be included?

I think it would make sense to give an alert about the ongoing tracking and then tell them to stop tracking before creating the report.

joshuaherrera commented 3 years ago

I like the idea. I'd imagine we could implement different commands / flags to customize the created report. We could use a --project <key> flag to grab all time logged on a project, or filter the report by time, e.g. a --month <month>, --week <weekNumber> or use a combination of --start and --end flags to get all time tracked for the month or week, or within some time frame, irrespective of project.

Thoughts or concerns?

dominikbraun commented 3 years ago

Since timetrace provides an interface to its config one other option could be to let the user change the lets say report-dir config field to whatever directory. The default could be in for example the ~/.timetrace/reports directory?

@KonstantinGasser Yes, we could introduce a config value for that, or an --output/-o flag, or even both.

KonstantinGasser commented 3 years ago

@dominikbraun I would be happy to implement a first proposal if that's ok.

KonstantinGasser commented 3 years ago

@dominikbraun for clarification I have one more question. The generated report is only for one project, right? So the user would call the command with the project name like so report <ProjectKey> and the report would hold all recorded records for this project? Or would report hold a list of all projects with its records?

dominikbraun commented 3 years ago

@dominikbraun for clarification I have one more question. The generated report is only for one project, right? So the user would call the command with the project name like so report <ProjectKey> and the report would hold all recorded records for this project? Or would report hold a list of all projects with its records?

Both use cases would make sense: Generating a report of all projects I've been working on from date X to date Y, as well as generating a report for a particular project.

Maybe it would be sufficient to generate a report for all projects by default and generate a report for a single project using a --project flag?

KonstantinGasser commented 3 years ago

Yes I feel this would be intuitive to have the ---project flag and else make a report for all records between the time frame. When it comes to the json output do you have anything special in mind here or would the following json ok? For all project: {key_1: [{},{}], key_2:[{},{}]...} For one project {key: [{},{}]}

dominikbraun commented 3 years ago

Yes, that should work if I'm not missing something 😄

KonstantinGasser commented 3 years ago

@dominikbraun I am almost done with this issue I just wanted to cross check the results with you and clarify one question.

When it comes the to output table I included a total time for each project. However, I am not sure whether each record-row in the table needs to display its total. Below I have three tables as an example. (for the project timetest I forgot to stop the tracking that's why it shows such a high total time 😄). I prefer the last table version as it looks more organised and structured - easy to understand

All rows with total
+-----------+---------+-------+------------+---------------+
|  PROJECT  |  START  |  END  |  BILLABLE  |     TOTAL     |
+-----------+---------+-------+------------+---------------+
| test      | 00:37   | 00:37 | no         | 0h 0min 9sec  |
| test      | 00:37   | 00:37 | no         | 0h 0min 9sec  |
| test      | ---     | ---   | ---        | 0h 0min 18sec |
| edittest  | 12:35   | 12:41 | no         | 0h 6min       |
| edittest  | 12:35   | 12:41 | no         | 0h 6min       |
| edittest  | 09:10   | 09:10 | no         | 0h 0min 20sec |
| edittest  | ---     | ---   | ---        | 0h 13min      |
| time      | 14:46   | 15:10 | no         | 0h 23min      |
| time      | 14:46   | 15:10 | no         | 0h 23min      |
| time      | ---     | ---   | ---        | 0h 47min      |
| seconly   | 15:10   | 15:11 | no         | 0h 0min 22sec |
| seconly   | 15:15   | 15:49 | no         | 0h 33min      |
| seconly   | 15:10   | 15:11 | no         | 0h 0min 22sec |
| seconly   | 15:15   | 15:49 | no         | 0h 33min      |
| seconly   | ---     | ---   | ---        | 1h 8min       |
| timetest  | 15:52   | 15:53 | no         | 0h 1min       |
| timetest  | 16:00   | 15:55 | no         | 23h 54min     |
| timetest  | 15:52   | 15:53 | no         | 0h 1min       |
| timetest  | 16:00   | 15:55 | no         | 23h 54min     |
| timetest  | ---     | ---   | ---        | 47h 50min     |
+-----------+---------+-------+------------+---------------+
Only project total
+-----------+---------+-------+------------+---------------+
|  PROJECT  |  START  |  END  |  BILLABLE  |     TOTAL     |
+-----------+---------+-------+------------+---------------+
| test      | 00:37   | 00:37 | no         |               |
| test      | 00:37   | 00:37 | no         |               |
| test      | ---     | ---   | ---        | 0h 0min 18sec |
| edittest  | 12:35   | 12:41 | no         |               |
| edittest  | 12:35   | 12:41 | no         |               |
| edittest  | 09:10   | 09:10 | no         |               |
| edittest  | ---     | ---   | ---        | 0h 13min      |
| time      | 14:46   | 15:10 | no         |               |
| time      | 14:46   | 15:10 | no         |               |
| time      | ---     | ---   | ---        | 0h 47min      |
| seconly   | 15:10   | 15:11 | no         |               |
| seconly   | 15:15   | 15:49 | no         |               |
| seconly   | 15:10   | 15:11 | no         |               |
| seconly   | 15:15   | 15:49 | no         |               |
| seconly   | ---     | ---   | ---        | 1h 8min       |
| timetest  | 15:52   | 15:53 | no         |               |
| timetest  | 16:00   | 15:55 | no         |               |
| timetest  | 15:52   | 15:53 | no         |               |
| timetest  | 16:00   | 15:55 | no         |               |
| timetest  | ---     | ---   | ---        | 47h 50min     |
+-----------+---------+-------+------------+---------------+
With blank row between projects
+-----------+---------+-------+------------+---------------+
|  PROJECT  |  START  |  END  |  BILLABLE  |     TOTAL     |
+-----------+---------+-------+------------+---------------+
| test      | 00:37   | 00:37 | no         |               |
| test      | 00:37   | 00:37 | no         |               |
| test      | ---     | ---   | ---        | 0h 0min 18sec |
|           |         |       |            |               |
| edittest  | 12:35   | 12:41 | no         |               |
| edittest  | 12:35   | 12:41 | no         |               |
| edittest  | 09:10   | 09:10 | no         |               |
| edittest  | ---     | ---   | ---        | 0h 13min      |
|           |         |       |            |               |
| time      | 14:46   | 15:10 | no         |               |
| time      | 14:46   | 15:10 | no         |               |
| time      | ---     | ---   | ---        | 0h 47min      |
|           |         |       |            |               |
| seconly   | 15:10   | 15:11 | no         |               |
| seconly   | 15:15   | 15:49 | no         |               |
| seconly   | 15:10   | 15:11 | no         |               |
| seconly   | 15:15   | 15:49 | no         |               |
| seconly   | ---     | ---   | ---        | 1h 8min       |
|           |         |       |            |               |
| timetest  | 15:52   | 15:53 | no         |               |
| timetest  | 16:00   | 15:55 | no         |               |
| timetest  | 15:52   | 15:53 | no         |               |
| timetest  | 16:00   | 15:55 | no         |               |
| timetest  | ---     | ---   | ---        | 47h 50min     |
+-----------+---------+-------+------------+---------------+
dominikbraun commented 3 years ago

Thanks, @KonstantinGasser! I'd also prefer the last one as it is the cleanest and simplest approach.

Tablewriter also supports table footers and cell merging. Maybe there is a way to make use of this for the individual projects or for all projects? In the current state of main, out.Table supports footers.

KonstantinGasser commented 3 years ago

@dominikbraun Cool I fetched the latest main and will try it out! Preferable would be to have a cell merging for each project and each project again as a "footer" with its total + a "group" total of all projects at the end, right?

dominikbraun commented 3 years ago

@dominikbraun Cool I fetched the latest main and will try it out! Preferable would be to have a cell merging for each project and each project again as a "footer" with its total + a "group" total of all projects at the end, right?

Yes, something like this. But you're totally free to choose the best looking variant 😎

KonstantinGasser commented 3 years ago

Ok I will experiment a little 😄

panmanio commented 3 years ago

Hi all,

two ideas for timetrace report:

dominikbraun commented 3 years ago

@maniowy Thanks for your suggestions! They both make sense and I created two issues for them: #140 and #141.

KonstantinGasser commented 3 years ago

just opened a PR closing #141

KonstantinGasser commented 3 years ago

also create a PR for filter by module, closing #140

c-nv-s commented 2 years ago

will tags be/optionally be output with the report as well?

dominikbraun commented 2 years ago

will tags be/optionally be output with the report as well?

There's issue #202 for that. If no PR will be opened, I'll implement that myself within the next few days.