Skip to content

Commit

Permalink
date ranges for yesterday
Browse files Browse the repository at this point in the history
- NEW: --before and --after for yesterday command
- NEW: --tag_order for yesterday command
- Docs update
  • Loading branch information
ttscoff committed Oct 14, 2021
1 parent d1414b9 commit a6d4ece
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### 1.0.88

- Add --before and --after time search to yesterday command
- Add --before and --after date search to search/grep command
- Add --tag_order to yesterday command

### 1.0.87

- Add leading spaces to make %shortdate align properly, at least for the last week
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ If you have a use for it, you can use `-o csv` on the show or view commands to o

`doing yesterday` is great for stand-ups (thanks to [Sean Collins](https://github.com/sc68cal) for that!). Note that you can show yesterday's activity from an alternate section by using the section name as an argument (e.g. `doing yesterday archive`).

All of the display commands (view, show, today, yesterday, search) support date ranges in addition to other filtering options. Results can be narrowed to a date/time span using `--before DATE` and `--after DATE`. The `DATE` accepts a natural language string but works best in formats like `10/20/21` or `2021-05-13 3pm` (or shortened to just `5/13 3pm`). For the `today` and `yesterday` commands the `DATE` should just be a time, e.g. `12pm` or `15:00`, and results will be filtered within the timespan for just that day. Both flags are optional, and you can use just `--before` to get everything older than a certain date, or use just `--after` to get everything newer.

`doing on` allows for full date ranges and filtering. `doing on saturday`, or `doing on one month to today` will give you ranges. You can use the same terms with the `show` command by adding the `-f` or `--from` flag. `doing show @done --from "monday to friday"` will give you all of your completed items for the last week (assuming it's the weekend). There's also `doing since` a simple alias for `doing on PAST_DATE to now`, e.g. `doing since monday`.

You can also show entries matching a search string with `doing grep` (synonym `doing search`). If you want to search with regular expressions or for an exact match, surround your search query with forward slashes, e.g. `doing search /project name/`. If you pass a search string without slashes, it's treated as a fuzzy search string, meaning matches can be found as long as the characters in the search string are in order and with no more than three other characters between each. By default searches are across all sections, but you can limit it to one with the `-s SECTION_NAME` flag. Searches can be displayed with the default template, or output as HTML, CSV, or JSON.
Expand Down
27 changes: 25 additions & 2 deletions bin/doing
Original file line number Diff line number Diff line change
Expand Up @@ -1324,10 +1324,33 @@ command :yesterday do |c|
c.arg_name 'KEY'
c.flag [:tag_sort], must_match: /^(?:name|time)$/i, default_value: default

c.desc 'View entries before specified time (e.g. 8am, 12:30pm, 15:00)'
c.arg_name 'TIME_STRING'
c.flag [:before]

c.desc 'View entries after specified time (e.g. 8am, 12:30pm, 15:00)'
c.arg_name 'TIME_STRING'
c.flag [:after]

c.desc 'Tag sort direction (asc|desc)'
c.arg_name 'DIRECTION'
c.flag [:tag_order], must_match: /^(?:a(?:sc)?|d(?:esc)?)$/i

c.action do |_global_options, options, _args|
tag_order = if options[:tag_order]
options[:tag_order] =~ /^d/i ? 'desc' : 'asc'
else
'asc'
end
options[:sort_tags] = options[:tag_sort] =~ /^n/i
puts wwid.yesterday(options[:s], options[:t], options[:o],
{ totals: options[:totals], sort_tags: options[:sort_tags] }).chomp
opt = {
after: options[:after],
before: options[:before],
sort_tags: options[:sort_tags],
tag_order: options[:tag_order],
totals: options[:totals]
}
puts wwid.yesterday(options[:section], options[:times], options[:output], opt).chomp
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/doing/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Doing
VERSION = '1.0.87'
VERSION = '1.0.88'
end
21 changes: 19 additions & 2 deletions lib/doing/wwid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2257,8 +2257,25 @@ def yesterday(section, times = nil, output = nil, opt = {})
opt[:totals] ||= false
opt[:sort_tags] ||= false
section = guess_section(section)
list_section({ section: section, count: 0, order: 'asc', yesterday: true, times: times,
output: output, totals: opt[:totals], sort_tags: opt[:sort_tags] })
y = (Time.now - (60 * 60 * 24)).strftime('%Y-%m-%d')
opt[:after] = "#{y} #{opt[:after]}" if opt[:after]
opt[:before] = "#{y} #{opt[:before]}" if opt[:before]

options = {
after: opt[:after],
before: opt[:before],
count: 0,
order: 'asc',
output: output,
section: section,
sort_tags: opt[:sort_tags],
tag_order: opt[:tag_order],
times: times,
totals: opt[:totals],
yesterday: true
}

list_section(options)
end

##
Expand Down

0 comments on commit a6d4ece

Please sign in to comment.