in backend/plugins/zentao/tasks/execution_extractor.go [38:134]
func ExtractExecutions(taskCtx plugin.SubTaskContext) errors.Error {
data := taskCtx.GetData().(*ZentaoTaskData)
extractor, err := api.NewApiExtractor(api.ApiExtractorArgs{
RawDataSubTaskArgs: api.RawDataSubTaskArgs{
Ctx: taskCtx,
Options: data.Options,
Table: RAW_EXECUTION_TABLE,
},
Extract: func(row *api.RawData) ([]interface{}, errors.Error) {
res := &models.ZentaoExecutionRes{}
err := json.Unmarshal(row.Data, res)
if err != nil {
return nil, errors.Default.WrapRaw(err)
}
var results []interface{}
for _, product := range res.Products {
p := &models.ZentaoProductSummary{
ConnectionId: data.Options.ConnectionId,
ProjectId: data.Options.ProjectId,
Id: product.ID,
Name: product.Name,
}
results = append(results, p)
}
execution := &models.ZentaoExecution{
ConnectionId: data.Options.ConnectionId,
Id: res.ID,
Project: res.Project,
ProjectId: res.Project,
Model: res.Model,
Type: res.Type,
Lifetime: res.Lifetime,
Budget: res.Budget,
BudgetUnit: res.BudgetUnit,
Attribute: res.Attribute,
Percent: res.Percent,
Milestone: res.Milestone,
Output: res.Output,
Auth: res.Auth,
Parent: res.Parent,
Path: res.Path,
Grade: res.Grade,
Name: res.Name,
Code: res.Code,
PlanBegin: res.PlanBegin,
PlanEnd: res.PlanEnd,
RealBegan: res.RealBegan,
RealEnd: res.RealEnd,
Status: res.Status,
SubStatus: res.SubStatus,
Pri: res.Pri,
Description: res.Description,
Version: res.Version,
ParentVersion: res.ParentVersion,
PlanDuration: res.PlanDuration,
RealDuration: res.RealDuration,
OpenedById: getAccountId(res.OpenedBy),
OpenedDate: res.OpenedDate,
OpenedVersion: res.OpenedVersion,
LastEditedById: getAccountId(res.LastEditedBy),
LastEditedDate: res.LastEditedDate,
ClosedById: getAccountId(res.ClosedBy),
ClosedDate: res.ClosedDate,
CanceledById: getAccountId(res.CanceledBy),
CanceledDate: res.CanceledDate,
SuspendedDate: res.SuspendedDate,
POId: getAccountId(res.PO),
PMId: getAccountId(res.PM),
QDId: getAccountId(res.QD),
RDId: getAccountId(res.RD),
Team: res.Team,
Acl: res.Acl,
OrderIn: res.OrderIn,
Vision: res.Vision,
DisplayCards: res.DisplayCards,
FluidBoard: res.FluidBoard,
Deleted: res.Deleted,
TotalHours: res.TotalHours,
TotalEstimate: res.TotalEstimate,
TotalConsumed: res.TotalConsumed,
TotalLeft: res.TotalLeft,
Progress: res.Progress,
CaseReview: res.CaseReview,
}
results = append(results, execution)
return results, nil
},
})
if err != nil {
return err
}
return extractor.Execute()
}