hours icon indicating copy to clipboard operation
hours copied to clipboard

Frame meta

Open matt-allan opened this issue 5 years ago • 1 comments

This issue builds on #41. You should be able to add custom metadata to frames. You can then use the metadata in reports.

# add custom meta fields
hours meta:add sprint
hours meta:add estimate --interval
hours meta:add velocity --computed 'estimate / elapsed'
hours meta:add points --number

# Track time with meta fields
hours start --tag migrations --notes 'adding emails table' --sprint 'bulbasaur' --estimate '20 minutes' --points 2

# Use meta in reports
hours report --sprint='bulbasaur'

Metadata can be defined as one of the following types:

  • string (default)
  • boolean
  • number
  • interval
  • datetime
  • timestamp
  • computed (will clarify in a separate issue)

Any field can optionally be variadic, which corresponds to passing multiple flags (i.e. how tags work now).

The field type is used to determine how it's (de)serialized for storage and how it's parsed from the CLI input.

Challenges:

Adding the meta option flags at runtime will be challenging, and will require additional database queries every time you run a command that supports meta. If we use the meta field name as the option name (and don't namespace them) adding any options in the future will technically be a breaking change.

Ideally we could store the meta as a JSON column, but to query JSON (i.e. for reports) requires the JSON1 extension for SQLite. Some PHP installations don't load this extension. We might be able to compile and distribute the shared library? It does work with Laravel, so it's a viable option.

I really don't want to have to do an EAV table for this, but that's an option too. Since SQLite doesn't have real date/time types every value would either be integer, real, or text.

matt-allan avatar Jul 27 '20 00:07 matt-allan

More info about how common the JSON1 extension is:

According to Django, most linux distros enable it by default.

It's enabled by Homebrew for Mac.

Can't find any info re: Windows.

Since JSON support will only be necessary for querying meta columns in reports and won't be used unless you use it explicitly it's probably OK if it doesn't work on certain platforms by default.

matt-allan avatar Jul 27 '20 00:07 matt-allan