From 266725a7f7b03f5db31e301493dea6162b7ed4aa Mon Sep 17 00:00:00 2001 From: d4x1 <1507509064@qq.com> Date: Mon, 8 Jul 2024 12:28:35 +0800 Subject: [PATCH] fix(zentao): make sure close_date must be before opened_date --- backend/plugins/zentao/tasks/bug_convertor.go | 6 ++++-- backend/plugins/zentao/tasks/story_convertor.go | 6 ++++-- backend/plugins/zentao/tasks/task_convertor.go | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/backend/plugins/zentao/tasks/bug_convertor.go b/backend/plugins/zentao/tasks/bug_convertor.go index 5c926cee63b..6a0f679b8a5 100644 --- a/backend/plugins/zentao/tasks/bug_convertor.go +++ b/backend/plugins/zentao/tasks/bug_convertor.go @@ -105,8 +105,10 @@ func ConvertBug(taskCtx plugin.SubTaskContext) errors.Error { if toolEntity.AssignedToId != 0 { domainEntity.AssigneeId = accountIdGen.Generate(data.Options.ConnectionId, toolEntity.AssignedToId) } - if toolEntity.ClosedDate != nil { - temp := uint(toolEntity.ClosedDate.ToNullableTime().Sub(toolEntity.OpenedDate.ToTime()).Minutes()) + closedDate := toolEntity.ClosedDate + openedDate := toolEntity.OpenedDate + if closedDate != nil && closedDate.ToTime().After(openedDate.ToTime()) { + temp := uint(closedDate.ToNullableTime().Sub(openedDate.ToTime()).Minutes()) domainEntity.LeadTimeMinutes = &temp } var results []interface{} diff --git a/backend/plugins/zentao/tasks/story_convertor.go b/backend/plugins/zentao/tasks/story_convertor.go index f9aea6aaafe..c8b072766eb 100644 --- a/backend/plugins/zentao/tasks/story_convertor.go +++ b/backend/plugins/zentao/tasks/story_convertor.go @@ -117,8 +117,10 @@ func ConvertStory(taskCtx plugin.SubTaskContext) errors.Error { results = append(results, issueAssignee) } - if toolEntity.ClosedDate != nil { - temp := uint(toolEntity.ClosedDate.ToNullableTime().Sub(toolEntity.OpenedDate.ToTime()).Minutes()) + closedDate := toolEntity.ClosedDate + openedDate := toolEntity.OpenedDate + if closedDate != nil && closedDate.ToTime().After(openedDate.ToTime()) { + temp := uint(closedDate.ToNullableTime().Sub(openedDate.ToTime()).Minutes()) domainEntity.LeadTimeMinutes = &temp } diff --git a/backend/plugins/zentao/tasks/task_convertor.go b/backend/plugins/zentao/tasks/task_convertor.go index 3489b6c29fe..43d8b94c280 100644 --- a/backend/plugins/zentao/tasks/task_convertor.go +++ b/backend/plugins/zentao/tasks/task_convertor.go @@ -108,8 +108,10 @@ func ConvertTask(taskCtx plugin.SubTaskContext) errors.Error { if toolEntity.AssignedToId != 0 { domainEntity.AssigneeId = accountIdGen.Generate(data.Options.ConnectionId, toolEntity.AssignedToId) } - if toolEntity.ClosedDate != nil { - temp := uint(toolEntity.ClosedDate.ToNullableTime().Sub(toolEntity.OpenedDate.ToTime()).Minutes()) + closedDate := toolEntity.ClosedDate + openedDate := toolEntity.OpenedDate + if closedDate != nil && closedDate.ToTime().After(openedDate.ToTime()) { + temp := uint(closedDate.ToNullableTime().Sub(openedDate.ToTime()).Minutes()) domainEntity.LeadTimeMinutes = &temp } var results []interface{}