Ignore subtasks, work around sections.any API bug
This commit is contained in:
@@ -7,6 +7,7 @@ import "strings"
|
||||
import "cloud.google.com/go/civil"
|
||||
|
||||
type SearchQuery struct {
|
||||
AssigneeAny []*User
|
||||
SectionsAny []*Section
|
||||
Completed *bool
|
||||
Due *bool
|
||||
@@ -26,11 +27,20 @@ func (wc *WorkspaceClient) Search(q *SearchQuery) ([]*Task, error) {
|
||||
path := fmt.Sprintf("workspaces/%s/tasks/search", wc.workspace.GID)
|
||||
|
||||
values := &url.Values{
|
||||
"is_subtask": []string{"false"},
|
||||
"sort_by": []string{"created_at"},
|
||||
"sort_ascending": []string{"true"},
|
||||
}
|
||||
|
||||
values.Add("opt_fields", "created_at,due_on,html_notes,name")
|
||||
values.Add("opt_fields", "assignee_section,created_at,due_on,html_notes,name")
|
||||
|
||||
if len(q.AssigneeAny) > 0 {
|
||||
gids := []string{}
|
||||
for _, u := range q.AssigneeAny {
|
||||
gids = append(gids, u.GID)
|
||||
}
|
||||
values.Add("assignee.any", strings.Join(gids, ","))
|
||||
}
|
||||
|
||||
if len(q.SectionsAny) > 0 {
|
||||
gids := []string{}
|
||||
|
||||
@@ -7,13 +7,18 @@ import "cloud.google.com/go/civil"
|
||||
import "golang.org/x/net/html"
|
||||
|
||||
type Task struct {
|
||||
GID string `json:"gid,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
DueOn string `json:"due_on,omitempty"`
|
||||
ParsedDueOn *civil.Date `json:"-"`
|
||||
HTMLNotes string `json:"html_notes,omitempty"`
|
||||
ParsedHTMLNotes *html.Node `json:"-"`
|
||||
GID string `json:"gid,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
CreatedAt string `json:"created_at,omitempty"`
|
||||
DueOn string `json:"due_on,omitempty"`
|
||||
ParsedDueOn *civil.Date `json:"-"`
|
||||
HTMLNotes string `json:"html_notes,omitempty"`
|
||||
ParsedHTMLNotes *html.Node `json:"-"`
|
||||
AssigneeSection *AssigneeSection `json:"assignee_section"`
|
||||
}
|
||||
|
||||
type AssigneeSection struct {
|
||||
GID string `json:"gid,omitempty"`
|
||||
}
|
||||
|
||||
type taskResponse struct {
|
||||
|
||||
Reference in New Issue
Block a user