dominikbraun / timetrace

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

Check record collisions when editing a record #187

Closed dominikbraun closed 2 years ago

dominikbraun commented 2 years ago

At the moment, record collision checks are only performed when creating a belated record using timetrace create record but not when editing an existing record.

This needs to be changed by calling t.RecordCollides when running timetrace edit record.


What is record collision?

Say you have 2 records:

And you want to insert a new one:

This record collides with the second (5PM - 8PM) record, because it lies within that record. timetrace doesn't allow this.

amoghrajesh commented 2 years ago

@dominikbraun I am interested in approaching this problem. Could you let me know how I can onboard myself and guide me where to edit the code?

dominikbraun commented 2 years ago

@amoghrajesh The code structure is pretty simple. All CLI commands, for example timetrace edit record, are in the cli package, and the files are named after the commands: All edit commands are in edit.go.

The edit record command is this variable:

https://github.com/dominikbraun/timetrace/blob/683e27d6caa067acce2b516106d85fab8ba3c2a6/cli/edit.go#L76-L122

The Run function contains the entire business logic.

There already is a function for determining if a record collides with others: t.RecordCollides(). It is already being used by the timetrace create record command:

https://github.com/dominikbraun/timetrace/blob/683e27d6caa067acce2b516106d85fab8ba3c2a6/cli/create.go#L103-L110

I think all you need to do is to call this function within the edit record command.

amoghrajesh commented 2 years ago

Can you assign this issue to me so that I can give it a shot? @dominikbraun