diff --git a/modules/dop/component-protocol/components/issue-gantt/gantt/render.go b/modules/dop/component-protocol/components/issue-gantt/gantt/render.go index 994ec9ce12e..a442bdf753f 100644 --- a/modules/dop/component-protocol/components/issue-gantt/gantt/render.go +++ b/modules/dop/component-protocol/components/issue-gantt/gantt/render.go @@ -57,18 +57,6 @@ func (f *ComponentGantt) Render(ctx context.Context, c *cptype.Component, scenar return err } - req := apistructs.IssuePagingRequest{ - IssueListRequest: apistructs.IssueListRequest{ - ProjectID: f.projectID, - Type: []apistructs.IssueType{apistructs.IssueTypeRequirement, apistructs.IssueTypeTask}, - IterationIDs: f.State.Values.IterationIDs, - Label: f.State.Values.LabelIDs, - Assignees: f.State.Values.AssigneeIDs, - }, - PageNo: 1, - PageSize: 500, - } - expand := make(map[uint64][]Item) switch event.Operation { case cptype.InitializeOperation, cptype.RenderingOperation: @@ -86,12 +74,31 @@ func (f *ComponentGantt) Render(ctx context.Context, c *cptype.Component, scenar }, } + req := apistructs.IssuePagingRequest{ + IssueListRequest: apistructs.IssueListRequest{ + ProjectID: f.projectID, + Type: []apistructs.IssueType{apistructs.IssueTypeRequirement, apistructs.IssueTypeTask}, + IterationIDs: f.State.Values.IterationIDs, + Label: f.State.Values.LabelIDs, + Assignees: f.State.Values.AssigneeIDs, + }, + PageNo: 1, + PageSize: 500, + } issues, _, err := f.issueSvc.GetIssueChildren(0, req) if err != nil { return err } expand[0] = f.convertIssueItem(issues) case cptype.OperationKey(apistructs.ExpandNode): + req := apistructs.IssuePagingRequest{ + IssueListRequest: apistructs.IssueListRequest{ + ProjectID: f.projectID, + Type: []apistructs.IssueType{apistructs.IssueTypeTask}, + }, + PageNo: 1, + PageSize: 500, + } for _, key := range op.Meta.Keys { issues, _, err := f.issueSvc.GetIssueChildren(key, req) if err != nil { diff --git a/modules/dop/dao/issue.go b/modules/dop/dao/issue.go index ee275cbfe12..e71b3537619 100644 --- a/modules/dop/dao/issue.go +++ b/modules/dop/dao/issue.go @@ -902,6 +902,10 @@ const ( func (client *DBClient) FindIssueChildren(id uint64, req apistructs.IssuePagingRequest) ([]IssueItem, uint64, error) { sql := client.Debug().Table("dice_issue_relation b").Joins(joinIssueChildren).Joins(joinStateNew). Where("b.issue_id = ? AND b.type = ?", id, apistructs.IssueRelationInclusion) + if id == 0 { + sql = client.Debug().Table("dice_issues as a").Joins(joinRelation, apistructs.IssueRelationInclusion).Joins(joinStateNew). + Where("b.id IS NULL") + } sql = sql.Where("a.deleted = 0").Where("a.project_id = ?", req.ProjectID) if len(req.Type) > 0 { sql = sql.Where("a.type IN (?)", req.Type) diff --git a/modules/dop/services/issue/issue.go b/modules/dop/services/issue/issue.go index 56f706e4f3d..3de78eeca1a 100644 --- a/modules/dop/services/issue/issue.go +++ b/modules/dop/services/issue/issue.go @@ -1601,13 +1601,13 @@ func (svc *Issue) GetIssueChildren(id uint64, req apistructs.IssuePagingRequest) if req.PageSize == 0 { req.PageSize = 20 } - if id == 0 { - requirements, tasks, total, err := svc.db.FindIssueRoot(req) - if err != nil { - return nil, 0, err - } - return append(requirements, tasks...), total, nil - } + // if id == 0 { + // requirements, tasks, total, err := svc.db.FindIssueRoot(req) + // if err != nil { + // return nil, 0, err + // } + // return append(requirements, tasks...), total, nil + // } return svc.db.FindIssueChildren(id, req) }