Skip to content

[bug] Cannot edit a record that had its initial timestamp edited #246

@pedroangelini

Description

@pedroangelini

If you edit a record's start timestamp (for example, changing the minutes of the record), you can no longer edit it using the timestamp as a key.

How to reproduce:

> timetrace create project dummy
✔️ Created project dummy

> timetrace start dummy
✔️ Started tracking time

> timetrace stop
✔️ Stopped tracking time

> timetrace list records today
+-----+------------------+---------------+---------+-------+------------+--------+
|  #  |       KEY        |    PROJECT    |  START  |  END  |  BILLABLE  |  TAGS  |
+-----+------------------+---------------+---------+-------+------------+--------+
|   4 | 2024-02-05-16-57 | dummy         | 16:57   | 16:57 | no         |        |
...

> timetrace edit 2024-02-05-16-57

In the editor, change the start time from 16:57 to 16:55
{
"start": "2024-02-05T16:5755:24.5205026+01:00",
"end": "2024-02-05T16:57:34.8433413+01:00",
"project": {
"key": "dummy"
},
"is_billable": false,
"tags": []
}

> timetrace list records today
+-----+------------------+---------------+---------+-------+------------+--------+
|  #  |       KEY        |    PROJECT    |  START  |  END  |  BILLABLE  |  TAGS  |
+-----+------------------+---------------+---------+-------+------------+--------+
|   4 | 2024-02-05-16-55 | dummy         | 16:55   | 16:57 | no         |        |
...

> timetrace edit record 2024-02-05-16-55
❗ failed to backup record before edit: record not found

The issue seems to be that the record file is still named 16-57 in the 2024-02-05 folder, so the edit command cannot find the file. Indeed if you try to edit using timetrace edit record 2024-02-05-16-57, you can still edit the record normally.

I see 2 possible solutions:

  1. after editing the record, rename the file to match the new record start time
  2. maintain the file name, and display it as the key of the record, which in the example above would look like the below (note the key and start times are no longer similar)
> timetrace list records today
+-----+------------------+---------------+---------+-------+------------+--------+
|  #  |       KEY        |    PROJECT    |  START  |  END  |  BILLABLE  |  TAGS  |
+-----+------------------+---------------+---------+-------+------------+--------+
|   4 | 2024-02-05-16-57 | dummy         | 16:55   | 16:57 | no         |        |

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions