likyh commented on code in PR #3680:
URL: 
https://github.com/apache/incubator-devlake/pull/3680#discussion_r1016363515


##########
services/task.go:
##########
@@ -194,6 +196,52 @@ func GetTasks(query *TaskQuery) ([]models.Task, int64, 
errors.Error) {
        return tasks, count, nil
 }
 
+// GetTasksWithLastStatus returns task list of the pipeline, only the most 
recently tasks would be returned
+func GetTasksWithLastStatus(pipelineId uint64) ([]models.Task, errors.Error) {
+       var tasks []models.Task
+       dbInner := db.Model(&models.Task{}).Order("id DESC").Where("pipeline_id 
= ?", pipelineId)
+       err := dbInner.Find(&tasks).Error
+       if err != nil {
+               return nil, errors.Convert(err)
+       }
+       taskIds := make(map[int64]struct{})
+       var result []models.Task
+       var maxRow, maxCol int
+       for _, task := range tasks {
+               if task.PipelineRow > maxRow {
+                       maxRow = task.PipelineRow
+               }
+               if task.PipelineCol > maxCol {
+                       maxCol = task.PipelineCol
+               }
+       }
+       for _, task := range tasks {
+               index := int64(task.PipelineRow)*int64(maxCol) + 
int64(task.PipelineCol)
+               if _, ok := taskIds[index]; !ok {
+                       taskIds[index] = struct{}{}
+                       result = append(result, task)
+               }
+       }
+       runningTasks.FillProgressDetailToTasks(result)
+       return result, nil
+}
+
+// SpawnTasks create new tasks from the failed ones
+func SpawnTasks(input []models.Task) ([]models.Task, errors.Error) {
+       var result []models.Task
+       for _, task := range input {
+               task.Model = common.Model{}
+               task.Status = models.TASK_CREATED
+               result = append(result, task)

Review Comment:
   does these task need to show in blueprint detail page?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to