Skip to content

Commit e767972

Browse files
committed
Fix: Task - Predecessors not being loaded
Task predecessors (dependencies) are only loaded when the `includeRelatedTasks` filter is provided. The SDK will now have the option to populate this filter. Comments were added to clarify the behaviour.
1 parent 14699ca commit e767972

1 file changed

Lines changed: 23 additions & 1 deletion

File tree

projects/task.go

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ type Task struct {
100100
Tags []twapi.Relationship `json:"tags"`
101101

102102
// Predecessors is the list of tasks that must be completed before this task
103-
// can be started or completed.
103+
// can be started or completed. This is only populated when providing the
104+
// IncludeRelatedTasks filter in the request.
104105
Predecessors []twapi.Relationship `json:"predecessors"`
105106

106107
// WorkflowStages is the list of workflow stages associated with this task.
@@ -607,12 +608,33 @@ const (
607608

608609
// TaskRequestFilters contains the filters for loading tasks.
609610
type TaskRequestFilters struct {
611+
// IncludeRelatedTasks IDs of active subtasks, dependencies and predecessors.
612+
// This will populate fields like Predecessors field in the response.
613+
IncludeRelatedTasks bool
614+
615+
// IncludeCompletedPredecessors indicates whether to include completed
616+
// predecessors.
617+
IncludeCompletedPredecessors bool
618+
619+
// IncludeTasksWithoutDueDates indicates whether to include tasks without due
620+
// dates. By default tasks without due dates are included.
621+
IncludeTasksWithoutDueDates *bool
622+
610623
// Include specifies related resources to include.
611624
Include []TaskRequestSideload
612625
}
613626

614627
func (p TaskRequestFilters) apply(req *http.Request) {
615628
query := req.URL.Query()
629+
if p.IncludeRelatedTasks {
630+
query.Set("includeRelatedTasks", "true")
631+
}
632+
if p.IncludeCompletedPredecessors {
633+
query.Set("includeCompletedPredecessors", "true")
634+
}
635+
if p.IncludeTasksWithoutDueDates != nil {
636+
query.Set("includeTasksWithoutDueDates", strconv.FormatBool(*p.IncludeTasksWithoutDueDates))
637+
}
616638
if len(p.Include) > 0 {
617639
includes := make([]string, len(p.Include))
618640
for i, include := range p.Include {

0 commit comments

Comments
 (0)