You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2024/03/28 12:41:00 UTC
(incubator-devlake) branch main updated: fix: upgrade tasks sort logic (#7239)
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 2f4035d28 fix: upgrade tasks sort logic (#7239)
2f4035d28 is described below
commit 2f4035d2893be1fd6db4a4c192716c5ad5c81ab8
Author: abeizn <zi...@merico.dev>
AuthorDate: Thu Mar 28 20:40:53 2024 +0800
fix: upgrade tasks sort logic (#7239)
---
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