You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by ab...@apache.org on 2024/03/28 10:26:48 UTC
(incubator-devlake) branch upgrade-tasks-sort-logic updated: fix: upgrade tasks sort logic
This is an automated email from the ASF dual-hosted git repository.
abeizn pushed a commit to branch upgrade-tasks-sort-logic
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/upgrade-tasks-sort-logic by this push:
new f8e78cc04 fix: upgrade tasks sort logic
f8e78cc04 is described below
commit f8e78cc04da25ebd91bdf802767efb5d36c8c7ea
Author: abeizn <zi...@merico.dev>
AuthorDate: Thu Mar 28 18:26:36 2024 +0800
fix: upgrade tasks sort logic
---
backend/server/services/task.go | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/backend/server/services/task.go b/backend/server/services/task.go
index 9ad7494a4..e01b0b225 100644
--- a/backend/server/services/task.go
+++ b/backend/server/services/task.go
@@ -332,23 +332,23 @@ func GetSubTasksInfo(pipelineId uint64, shouldSanitize bool, tx dal.Dal) (*model
// filterTasksWithLastStatus returns the latest task for each plugin
func filterTasksWithLastStatus(tasks []*models.Task) []*models.Task {
taskMap := make(map[string]*models.Task)
- sortedTasks := tasks
for _, task := range tasks {
- if existingTask, ok := taskMap[task.Plugin]; ok {
+ key := fmt.Sprintf("%d-%d-%d", task.PipelineId, task.PipelineRow, task.PipelineCol)
+ if existingTask, ok := taskMap[key]; ok {
if task.BeganAt != nil && (existingTask.BeganAt == nil || task.BeganAt.After(*existingTask.BeganAt)) {
- taskMap[task.Plugin] = task
+ taskMap[key] = task
}
} else {
- taskMap[task.Plugin] = task
+ taskMap[key] = task
}
}
var filteredTasks []*models.Task
- for _, task := range taskMap {
- filteredTasks = append(filteredTasks, task)
- }
- for i, task := range sortedTasks {
- filteredTasks[i] = taskMap[task.Plugin]
+ for _, task := range tasks {
+ key := fmt.Sprintf("%d-%d-%d", task.PipelineId, task.PipelineRow, task.PipelineCol)
+ if filteredTask, ok := taskMap[key]; ok {
+ filteredTasks = append(filteredTasks, filteredTask)
+ }
}
return filteredTasks