Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check record collisions when editing a record #203

Open
dominikbraun opened this issue Dec 3, 2021 · 5 comments
Open

Check record collisions when editing a record #203

dominikbraun opened this issue Dec 3, 2021 · 5 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@dominikbraun
Copy link
Owner

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:

  • 3PM - 4PM
  • 5PM - 8PM

And you want to insert a new one:

  • 7PM - 9PM

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

@dominikbraun dominikbraun added enhancement New feature or request help wanted Extra attention is needed labels Dec 3, 2021
@dsa0x
Copy link

dsa0x commented Jan 20, 2022

Hi. I am trying to work on this. Is there anything that uniquely identifies a record?
I made it work for the EditRecord method, but for the EditRecordManual, it's a bit trickier, since the file editing is done in vim/an external editor.

@dominikbraun
Copy link
Owner Author

@dsa0x The unique identifier for a record is its timestamp (start time). Quite frankly, I think the only way to handle record collisions when editing a record manually is to wait until the user has saved the file (i.e. after the t.EditRecordManual(recordTime) call in edit.go), check for collisions, print an error if there is a collision and revert the file to the previous state so that the record remains valid. This can be done using a t.RevertRecord(recordTime) call if I'm not wrong.

@dsa0x
Copy link

dsa0x commented Jan 20, 2022

@dominikbraun I think so too. That's kinda what I did. I simply called t.loadRecordafter cmd.Run, to fetch the file again. But if one edits the start time, then this timestamp changes, and it becomes impossible to track the record. Also, your suggestion might work if we assume that the startTime will not be changed. Is that safe to assume? (meaning if the user changes it, unexpected behaviors will occur)

@dominikbraun
Copy link
Owner Author

@dsa0x Right, that's an issue and there is PR #89 to fix this. Speaking of this PR, it probably would make sense to merge it before you implement the collision check...

@dsa0x
Copy link

dsa0x commented Jan 20, 2022

Okay. Cool. I'll wait then. In the meantime, you can assign me to this. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants