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


##########
runner/run_pipeline.go:
##########
@@ -37,43 +36,46 @@ func RunPipeline(
        pipelineId uint64,
        runTasks func([]uint64) errors.Error,
 ) errors.Error {
-       startTime := time.Now()
-       // load pipeline from db
-       dbPipeline := &models.DbPipeline{}
-       err := db.Find(dbPipeline, pipelineId).Error
-       if err != nil {
-               return errors.Convert(err)
-       }
        // load tasks for pipeline
-       var tasks []*models.Task
-       err = db.Where("pipeline_id = ?", dbPipeline.ID).Order("pipeline_row, 
pipeline_col").Find(&tasks).Error
+       var tasks []models.Task
+       err := db.Where("pipeline_id = ? AND status = ?", pipelineId, 
models.TASK_CREATED).Order("pipeline_row, pipeline_col").Find(&tasks).Error
        if err != nil {
                return errors.Convert(err)
        }
-       if len(tasks) != dbPipeline.TotalTasks {
-               return errors.Internal.New(fmt.Sprintf("expected total tasks to 
be %v, got %v", dbPipeline.TotalTasks, len(tasks)))
-       }
-       // convert to 2d array
+       sort.Slice(tasks, func(i, j int) bool {
+               if tasks[i].PipelineRow < tasks[j].PipelineRow {
+                       return true
+               } else if tasks[i].PipelineRow == tasks[j].PipelineRow {
+                       return tasks[i].PipelineCol < tasks[j].PipelineCol
+               }
+               return true

Review Comment:
   Let's add some unit-test here to confirm 2d array are generated as expected.



-- 
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