|
|
@ -55,23 +55,30 @@ func (r *Result) Requirement(id int) *RequirementResult { |
|
|
|
} |
|
|
|
|
|
|
|
type RequirementResult struct { |
|
|
|
ID int `json:"id"` |
|
|
|
Name string `json:"name"` |
|
|
|
Description string `json:"description"` |
|
|
|
Status models.Status `json:"status"` |
|
|
|
StatusName string `json:"statusName"` |
|
|
|
TotalAcquired float64 `json:"totalAcquired"` |
|
|
|
TotalRequired float64 `json:"totalRequired"` |
|
|
|
TotalPlanned float64 `json:"totalPlanned"` |
|
|
|
IsCoarse bool `json:"isCoarse"` |
|
|
|
AggregateRequired int `json:"aggregateRequired"` |
|
|
|
Stats []RequirementResultStat `json:"stats"` |
|
|
|
Items []items.Result `json:"items,omitempty"` |
|
|
|
Tags []string `json:"tags"` |
|
|
|
ID int `json:"id"` |
|
|
|
Name string `json:"name"` |
|
|
|
Description string `json:"description"` |
|
|
|
Status models.Status `json:"status"` |
|
|
|
StatusName string `json:"statusName"` |
|
|
|
TotalAcquired float64 `json:"totalAcquired"` |
|
|
|
TotalRequired float64 `json:"totalRequired"` |
|
|
|
TotalPlanned float64 `json:"totalPlanned"` |
|
|
|
IsCoarse bool `json:"isCoarse"` |
|
|
|
AggregateRequired int `json:"aggregateRequired"` |
|
|
|
Stats []RequirementResultStat `json:"stats"` |
|
|
|
Items []items.Result `json:"items,omitempty"` |
|
|
|
Tags []string `json:"tags"` |
|
|
|
Project *RequirementResultProject `json:"project,omitempty"` |
|
|
|
|
|
|
|
Requirement entities.Requirement `json:"-"` |
|
|
|
} |
|
|
|
|
|
|
|
type RequirementResultProject struct { |
|
|
|
ID int `json:"id"` |
|
|
|
ScopeID int `json:"scopeId"` |
|
|
|
Name string `json:"name"` |
|
|
|
} |
|
|
|
|
|
|
|
func (r *RequirementResult) Stat(id int) *RequirementResultStat { |
|
|
|
for _, stat := range r.Stats { |
|
|
|
if stat.ID == id { |
|
|
@ -137,7 +144,7 @@ func generateResult( |
|
|
|
continue |
|
|
|
} |
|
|
|
|
|
|
|
resReq := generateRequirementResult(req, scope, requirementStats, projectItems) |
|
|
|
resReq := generateRequirementResult(req, scope, requirementStats, projectItems, nil) |
|
|
|
|
|
|
|
res.TotalRequired += resReq.TotalRequired |
|
|
|
res.TotalPlanned += resReq.TotalPlanned |
|
|
@ -163,7 +170,7 @@ func generateResult( |
|
|
|
return &res |
|
|
|
} |
|
|
|
|
|
|
|
func generateRequirementResult(req entities.Requirement, scope scopes.Result, requirementStats []entities.RequirementStat, projectItems []items.Result) RequirementResult { |
|
|
|
func generateRequirementResult(req entities.Requirement, scope scopes.Result, requirementStats []entities.RequirementStat, projectItems []items.Result, projects []entities.Project) RequirementResult { |
|
|
|
resReq := RequirementResult{ |
|
|
|
ID: req.ID, |
|
|
|
Name: req.Name, |
|
|
@ -287,5 +294,17 @@ func generateRequirementResult(req entities.Requirement, scope scopes.Result, re |
|
|
|
resReq.Items = nil |
|
|
|
} |
|
|
|
|
|
|
|
for _, project := range projects { |
|
|
|
if project.ID == req.ProjectID { |
|
|
|
resReq.Project = &RequirementResultProject{ |
|
|
|
ID: project.ID, |
|
|
|
ScopeID: project.ScopeID, |
|
|
|
Name: project.Name, |
|
|
|
} |
|
|
|
|
|
|
|
break |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return resReq |
|
|
|
} |