Ignore subtasks, work around sections.any API bug

This commit is contained in:
Ian Gulliver
2022-05-18 03:45:31 +00:00
parent 38856c9b39
commit 476fba27e6
4 changed files with 58 additions and 24 deletions

View File

@@ -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{}