func()

in backend/plugins/zentao/tasks/task_extractor.go [90:178]


func (c *taskExtractor) toZentaoTasks(accountCache *AccountCache, res *models.ZentaoTaskRes, url string, tasks *[]*models.ZentaoTask) {
	task := &models.ZentaoTask{
		ConnectionId:       c.connectionId,
		ID:                 res.Id,
		Project:            res.Project,
		Parent:             res.Parent,
		Execution:          res.Execution,
		Module:             res.Module,
		Design:             res.Design,
		Story:              res.Story,
		StoryVersion:       res.StoryVersion,
		DesignVersion:      res.DesignVersion,
		FromBug:            res.FromBug,
		Feedback:           res.Feedback,
		FromIssue:          res.FromIssue,
		Name:               res.Name,
		Type:               res.Type,
		Mode:               res.Mode,
		Pri:                res.Pri,
		Estimate:           res.Estimate,
		Consumed:           res.Consumed,
		Left:               res.Left,
		Deadline:           res.Deadline,
		Status:             res.Status,
		SubStatus:          res.SubStatus,
		Color:              res.Color,
		Description:        res.Description,
		Version:            res.Version,
		OpenedById:         accountCache.getAccountIDFromApiAccount(res.OpenedBy),
		OpenedByName:       accountCache.getAccountNameFromApiAccount(res.OpenedBy),
		OpenedDate:         res.OpenedDate,
		AssignedToId:       accountCache.getAccountIDFromApiAccount(res.AssignedTo),
		AssignedToName:     accountCache.getAccountNameFromApiAccount(res.AssignedTo),
		AssignedDate:       res.AssignedDate,
		EstStarted:         res.EstStarted,
		RealStarted:        res.RealStarted,
		FinishedId:         accountCache.getAccountIDFromApiAccount(res.FinishedBy),
		FinishedDate:       res.FinishedDate,
		FinishedList:       res.FinishedList,
		CanceledId:         accountCache.getAccountIDFromApiAccount(res.CanceledBy),
		CanceledDate:       res.CanceledDate,
		ClosedById:         accountCache.getAccountIDFromApiAccount(res.ClosedBy),
		ClosedDate:         res.ClosedDate,
		PlanDuration:       res.PlanDuration,
		RealDuration:       res.RealDuration,
		ClosedReason:       res.ClosedReason,
		LastEditedId:       accountCache.getAccountIDFromApiAccount(res.LastEditedBy),
		LastEditedDate:     res.LastEditedDate,
		ActivatedDate:      res.ActivatedDate,
		OrderIn:            res.OrderIn,
		Repo:               res.Repo,
		Mr:                 res.Mr,
		Entry:              res.Entry,
		NumOfLine:          res.NumOfLine,
		V1:                 res.V1,
		V2:                 res.V2,
		Vision:             res.Vision,
		StoryID:            res.Story,
		StoryTitle:         res.StoryTitle,
		LatestStoryVersion: 0,
		AssignedToRealName: res.AssignedToRealName,
		PriOrder:           res.PriOrder,
		NeedConfirm:        res.NeedConfirm,
		Progress:           res.Progress,
		Url:                url,
	}

	task.StdType = c.stdTypeMappings[task.Type]
	if task.StdType == "" {
		task.StdType = ticket.TASK
	}
	if len(c.statusMappings) != 0 {
		if stdStatus, ok := c.statusMappings[task.Status]; ok {
			task.StdStatus = stdStatus
		} else {
			task.StdStatus = task.Status
		}
	} else {
		task.StdStatus = ticket.GetStatus(&ticket.StatusRule{
			Done:    []string{"done", "closed", "cancel"},
			Todo:    []string{"wait"},
			Default: ticket.IN_PROGRESS,
		}, task.Status)
	}
	*tasks = append(*tasks, task)
	for _, child := range res.Children {
		c.toZentaoTasks(accountCache, child, url, tasks)
	}
}