bartib icon indicating copy to clipboard operation
bartib copied to clipboard

Add grouping to the output of list

Open Niatross opened this issue 1 year ago • 7 comments

When running the list command it would be useful to have the option to group the output by project and/or description and provide totals for each group.

An example output could be:

2025-02-10 Project A 5h 00m 09:00   10:00   task A            Project A                    1h 00m   10:00   13:00   task B           Project A                     3h 00m   15:00   16:00   task A           Project A                     1h 00m  

Project B 4h 30m 13:00   14:30   task A    Project B                               1h 30m   13:00   14:30   task B     Project B                               1h 30m   13:00   14:30   task A     Project B                               1h 30m  

Grouping by task and project could output

2025-02-10 Project A taskA 2h 00m 09:00   10:00   task A            Project A                    1h 00m   15:00   16:00   task A           Project A                     1h 00m  

Project A taskB 3h 00m 10:00   13:00   task B           Project A                     3h 00m  

Project B task A 3h 00m 13:00   14:30   task A    Project B                               1h 30m   13:00   14:30   task A     Project B                               1h 30m  

Project B task B 1h 30m 13:00   14:30   task B     Project B                               1h 30m  

I suggest adding the following flags --group_project - gp --group_description -gd

Niatross avatar Feb 26 '25 11:02 Niatross

I can actively work on this and provide a pull request shortly

Niatross avatar Feb 26 '25 11:02 Niatross

How would this differ from bartib report?

nikolassv avatar Feb 27 '25 14:02 nikolassv

This differs because the report functionality provides totals for each project calculated over the date range provided.

In organisations where you have to provide a day by day breakdown of time this is not useful.

Perhaps the functionality I suggested should be part of the report function though, maybe via a --daily flag?

Niatross avatar Feb 28 '25 08:02 Niatross

Ok, I see how this would be useful. It would be a nice enhancement for the report subcommand. If the user defines a time range which spans over several days and sets the --daily flag it would give a report for each individual day. In every other case it would work like before.

nikolassv avatar Feb 28 '25 09:02 nikolassv

Upon further thought, I am going to propose that we add a --group option which accepts combinations of the following characters: p - project d - description c - calendar (date)

The combination and order determines what grouping is applied to the report action.

some examples are (with poorly formatted outputs): bartib report -g cpd this would generate a report showing the total duration for descriptions in projects in days

2025-02-10 2h 00m
    Project B 2h 00m
        task A   1h 00m  
        task B   1h 00m  

2025-02-11 2h 00m
    Project B 2h 00m
        task A   1h 00m  
        task B   1h 00m  

bartib report -g dpc

task A 2h 00m
    Project A 2h 00m
        2025-02-10 1h 00m
        2025-02-11 1h 00m
    Project B 2h 00m
        2025-02-10 1h 00m
        2025-02-11 1h 00m

task B 2h 00m
    Project A 2h 00m
        2025-02-10 1h 00m
        2025-02-11 1h 00m
    Project B 2h 00m
        2025-02-10 1h 00m
        2025-02-11 1h 00m

The existing report functionality is the equivalent of the command below (This could be left as the default functionality): bartib report -g pd

Niatross avatar Mar 18 '25 12:03 Niatross

This looks nice. I think it could work very well like this. If you would like to implement this, I would be happy to accept a pull request.

nikolassv avatar Apr 02 '25 07:04 nikolassv

I have a working version of this, I just need to tidy it up and implement some error handling and I will issue a PR

Niatross avatar Apr 02 '25 15:04 Niatross