Skip to content

Commit

Permalink
filter completed items at today sub-command
Browse files Browse the repository at this point in the history
  • Loading branch information
kobtea committed Sep 10, 2018
1 parent d22082e commit 1985a9b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cmd/todoist/cmd/today.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ var todayCmd = &cobra.Command{
if err != nil {
return err
}
items := client.Item.FindByDueDate(todoist.Today())
var items []todoist.Item
for _, i := range client.Item.FindByDueDate(todoist.Today()) {
if !i.IsChecked() {
items = append(items, i)
}
}
sort.Slice(items, func(i, j int) bool {
return items[i].DueDateUtc.Before(items[j].DueDateUtc)
})
Expand Down
7 changes: 7 additions & 0 deletions todoist/item.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ func (i Item) IsOverDueDate() bool {
return i.DueDateUtc.Before(Time{time.Now().UTC()})
}

func (i Item) IsChecked() bool {
if i.Checked == 1 {
return true
}
return false
}

type ItemClient struct {
*Client
cache *itemCache
Expand Down

0 comments on commit 1985a9b

Please sign in to comment.