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 2022/06/21 09:19:44 UTC
[incubator-devlake] branch main updated: fix(tapd): ignore err if it's record not found
This is an automated email from the ASF dual-hosted git repository.
abeizn 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 1922ac80 fix(tapd): ignore err if it's record not found
1922ac80 is described below
commit 1922ac80bec6b2604a7733504bdcb14677971237
Author: Yingchu Chen <yi...@merico.dev>
AuthorDate: Tue Jun 21 17:09:14 2022 +0800
fix(tapd): ignore err if it's record not found
---
plugins/tapd/impl/impl.go | 15 ++++++++-------
plugins/tapd/tasks/bug_changelog_collector.go | 2 +-
plugins/tapd/tasks/bug_collector.go | 2 +-
plugins/tapd/tasks/bug_commit_collector.go | 2 +-
plugins/tapd/tasks/iteration_collector.go | 2 +-
plugins/tapd/tasks/story_changelog_collector.go | 2 +-
plugins/tapd/tasks/story_collector.go | 2 +-
plugins/tapd/tasks/story_commit_collector.go | 2 +-
plugins/tapd/tasks/task_changelog_collector.go | 2 +-
plugins/tapd/tasks/task_collector.go | 2 +-
plugins/tapd/tasks/task_commit_collector.go | 2 +-
plugins/tapd/tasks/worklog_collector.go | 2 +-
12 files changed, 19 insertions(+), 18 deletions(-)
diff --git a/plugins/tapd/impl/impl.go b/plugins/tapd/impl/impl.go
index 05f8ed29..400702ab 100644
--- a/plugins/tapd/impl/impl.go
+++ b/plugins/tapd/impl/impl.go
@@ -19,7 +19,7 @@ package impl
import (
"fmt"
- "github.com/apache/incubator-devlake/plugins/core/dal"
+ "github.com/apache/incubator-devlake/plugins/helper"
"time"
"github.com/apache/incubator-devlake/migration"
@@ -115,23 +115,24 @@ func (plugin Tapd) SubTaskMetas() []core.SubTaskMeta {
}
func (plugin Tapd) PrepareTaskData(taskCtx core.TaskContext, options map[string]interface{}) (interface{}, error) {
- db := taskCtx.GetDal()
var op tasks.TapdOptions
err := mapstructure.Decode(options, &op)
if err != nil {
return nil, err
}
if op.ConnectionId == 0 {
- return nil, fmt.Errorf("ConnectionId is required for Tapd execution")
+ return nil, fmt.Errorf("connectionId is invalid")
}
connection := &models.TapdConnection{}
- clauses := []dal.Clause{
- dal.Where("connection_id = ?", op.ConnectionId),
- }
- err = db.First(connection, clauses...)
+ connectionHelper := helper.NewConnectionHelper(
+ taskCtx,
+ nil,
+ )
+ err = connectionHelper.FirstById(connection, op.ConnectionId)
if err != nil {
return nil, err
}
+
var since time.Time
if op.Since != "" {
since, err = time.Parse("2006-01-02T15:04:05Z", op.Since)
diff --git a/plugins/tapd/tasks/bug_changelog_collector.go b/plugins/tapd/tasks/bug_changelog_collector.go
index ce7632c2..39b931ff 100644
--- a/plugins/tapd/tasks/bug_changelog_collector.go
+++ b/plugins/tapd/tasks/bug_changelog_collector.go
@@ -46,7 +46,7 @@ func CollectBugChangelogs(taskCtx core.SubTaskContext) error {
dal.Orderby("created DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/bug_collector.go b/plugins/tapd/tasks/bug_collector.go
index bfc159ce..1ffcf120 100644
--- a/plugins/tapd/tasks/bug_collector.go
+++ b/plugins/tapd/tasks/bug_collector.go
@@ -47,7 +47,7 @@ func CollectBugs(taskCtx core.SubTaskContext) error {
dal.Orderby("modified DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/bug_commit_collector.go b/plugins/tapd/tasks/bug_commit_collector.go
index 190f9459..9729c6ab 100644
--- a/plugins/tapd/tasks/bug_commit_collector.go
+++ b/plugins/tapd/tasks/bug_commit_collector.go
@@ -54,7 +54,7 @@ func CollectBugCommits(taskCtx core.SubTaskContext) error {
dal.Orderby("created DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/iteration_collector.go b/plugins/tapd/tasks/iteration_collector.go
index 6a45f5f2..f2cf99dc 100644
--- a/plugins/tapd/tasks/iteration_collector.go
+++ b/plugins/tapd/tasks/iteration_collector.go
@@ -48,7 +48,7 @@ func CollectIterations(taskCtx core.SubTaskContext) error {
dal.Orderby("created DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/story_changelog_collector.go b/plugins/tapd/tasks/story_changelog_collector.go
index 75133a9b..4fe9f34c 100644
--- a/plugins/tapd/tasks/story_changelog_collector.go
+++ b/plugins/tapd/tasks/story_changelog_collector.go
@@ -46,7 +46,7 @@ func CollectStoryChangelogs(taskCtx core.SubTaskContext) error {
dal.Orderby("created DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/story_collector.go b/plugins/tapd/tasks/story_collector.go
index 23eaf627..ff7f4fb2 100644
--- a/plugins/tapd/tasks/story_collector.go
+++ b/plugins/tapd/tasks/story_collector.go
@@ -46,7 +46,7 @@ func CollectStorys(taskCtx core.SubTaskContext) error {
dal.Orderby("modified DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/story_commit_collector.go b/plugins/tapd/tasks/story_commit_collector.go
index e2986881..a6cbe7e1 100644
--- a/plugins/tapd/tasks/story_commit_collector.go
+++ b/plugins/tapd/tasks/story_commit_collector.go
@@ -54,7 +54,7 @@ func CollectStoryCommits(taskCtx core.SubTaskContext) error {
dal.Orderby("created DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/task_changelog_collector.go b/plugins/tapd/tasks/task_changelog_collector.go
index e0b425f2..5be10e5b 100644
--- a/plugins/tapd/tasks/task_changelog_collector.go
+++ b/plugins/tapd/tasks/task_changelog_collector.go
@@ -46,7 +46,7 @@ func CollectTaskChangelogs(taskCtx core.SubTaskContext) error {
dal.Orderby("created DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/task_collector.go b/plugins/tapd/tasks/task_collector.go
index e52e4158..bcb2d23b 100644
--- a/plugins/tapd/tasks/task_collector.go
+++ b/plugins/tapd/tasks/task_collector.go
@@ -48,7 +48,7 @@ func CollectTasks(taskCtx core.SubTaskContext) error {
dal.Orderby("modified DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/task_commit_collector.go b/plugins/tapd/tasks/task_commit_collector.go
index 1c546fd5..bbd490af 100644
--- a/plugins/tapd/tasks/task_commit_collector.go
+++ b/plugins/tapd/tasks/task_commit_collector.go
@@ -54,7 +54,7 @@ func CollectTaskCommits(taskCtx core.SubTaskContext) error {
dal.Orderby("created DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {
diff --git a/plugins/tapd/tasks/worklog_collector.go b/plugins/tapd/tasks/worklog_collector.go
index 67b66647..4271f8db 100644
--- a/plugins/tapd/tasks/worklog_collector.go
+++ b/plugins/tapd/tasks/worklog_collector.go
@@ -46,7 +46,7 @@ func CollectWorklogs(taskCtx core.SubTaskContext) error {
dal.Orderby("created DESC"),
}
err := db.First(&latestUpdated, clauses...)
- if err != nil {
+ if err != nil && err.Error() != "record not found" {
return fmt.Errorf("failed to get latest tapd changelog record: %w", err)
}
if latestUpdated.Id > 0 {