GothenburgBitFactory / GothenburgBitFactory/timewarrior
Use JSON for undo.data
- Dominant language
- C++
- Stars
- 1.7k
- Forks
- 117
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 5
Description
Using JSON objects to store transactions could make extending the undo-database easier
Instead of
```
$ timew start FOO 1h ago
$ timew start BAR 30min ago
$ timew tag BAZ
```
creating
```
txn:
type: interval
before:
after: {"id":0,"start":"20200805T145413Z","tags":["FOO"]}
txn:
type: interval
before: {"id":1,"start":"20200805T145413Z","tags":["FOO"]}
after:
type: interval
before:
after: {"id":1,"start":"20200805T145413Z","end":"20200805T152424Z","tags":["FOO"]}
type: interval
before:
after: {"id":0,"start":"20200805T152424Z","tags":["BAR"]}
txn:
type: interval
before: {"id":1,"start":"20200805T152424Z","tags":["BAR"]}
after:
type: interval
before:
after: {"id":1,"start":"20200805T152424Z","tags":["BAR","BAZ"]}
```
create a JSON-Object for every transaction.
When extending `Journal::startTransaction` with a string parameter to reflect the command, the result could look like this:
```
{
"cli": "start FOO 1h ago",
"actions": [
{
"type": "interval",
"before": null,
"after": {"id": 0, "start": "20200805T145413Z", "tags": ["FOO"]}
}
]
}
{
"cli": "start BAR 30min ago",
"actions": [
{
"type": "interval",
"before": {"id":1,"start":"20200805T145413Z","tags":["FOO"]},
"after": null,
},
{
"type": "interval"
"before": null
"after": {"id":1,"start":"20200805T145413Z","end":"20200805T152424Z","tags":["FOO"]}
},
{
"type": "interval"
"before": null
"after": {"id":0,"start":"20200805T152424Z","tags":["BAR"]}
}
]
}
{
"cli": "tag BAZ",
"actions": [
{
"type": "interval"
"before": {"id":1,"start":"20200805T152424Z","tags":["BAR"]}
"after": null
},
{
"type": "interval"
"before": null
"after": {"id":1,"start":"20200805T152424Z","tags":["BAR","BAZ"]},
}
]
}
```
Of course, in the actual `undo.data` there would be one JSON line per transaction.
Contributor guide
Research direction
Start by reviewing Journal::startTransaction and the existing undo.data handling. Define the transaction JSON structure described in the issue, including cli and actions with before/after values, and ensure undo.data contains one JSON line per transaction.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100