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
commit 8cf9d9e66affa89e91a840eadcae3bbe3d8e3493 Author: abeizn <[email protected]> AuthorDate: Thu Jun 23 15:53:28 2022 +0800 fix: jira record not found --- plugins/gitlab/tasks/issue_collector.go | 13 ++++--------- plugins/jira/tasks/issue_collector.go | 6 +++--- plugins/tapd/tasks/bug_changelog_collector.go | 3 ++- plugins/tapd/tasks/bug_collector.go | 3 ++- plugins/tapd/tasks/bug_commit_collector.go | 3 ++- plugins/tapd/tasks/iteration_collector.go | 3 ++- plugins/tapd/tasks/shared.go | 5 +++-- plugins/tapd/tasks/story_changelog_collector.go | 8 ++++---- plugins/tapd/tasks/story_collector.go | 3 ++- plugins/tapd/tasks/story_commit_collector.go | 3 ++- plugins/tapd/tasks/task_changelog_collector.go | 3 ++- plugins/tapd/tasks/task_collector.go | 3 ++- plugins/tapd/tasks/task_commit_collector.go | 3 ++- plugins/tapd/tasks/worklog_collector.go | 3 ++- 14 files changed, 34 insertions(+), 28 deletions(-) diff --git a/plugins/gitlab/tasks/issue_collector.go b/plugins/gitlab/tasks/issue_collector.go index e5732e25..2aa7cefb 100644 --- a/plugins/gitlab/tasks/issue_collector.go +++ b/plugins/gitlab/tasks/issue_collector.go @@ -20,23 +20,18 @@ package tasks import ( "encoding/json" "fmt" - "github.com/apache/incubator-devlake/plugins/core/dal" + "gorm.io/gorm" "net/http" "net/url" - "github.com/apache/incubator-devlake/plugins/helper" - "github.com/apache/incubator-devlake/plugins/core" + "github.com/apache/incubator-devlake/plugins/core/dal" "github.com/apache/incubator-devlake/plugins/gitlab/models" + "github.com/apache/incubator-devlake/plugins/helper" ) const RAW_ISSUE_TABLE = "gitlab_api_issues" -//This Struct was declared in shared.go -//type GitlabApiParams struct { -// ProjectId int -//} - var CollectApiIssuesMeta = core.SubTaskMeta{ Name: "collectApiIssues", EntryPoint: CollectApiIssues, @@ -57,7 +52,7 @@ func CollectApiIssues(taskCtx core.SubTaskContext) error { dal.Orderby("gitlab_updated_at DESC"), } err := db.First(&latestUpdated, clause...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { return fmt.Errorf("failed to get latest gitlab issue record: %w", err) } if latestUpdated.GitlabId > 0 { diff --git a/plugins/jira/tasks/issue_collector.go b/plugins/jira/tasks/issue_collector.go index 58033af1..e9d23c05 100644 --- a/plugins/jira/tasks/issue_collector.go +++ b/plugins/jira/tasks/issue_collector.go @@ -24,11 +24,11 @@ import ( "net/http" "net/url" - "github.com/apache/incubator-devlake/plugins/core/dal" - "github.com/apache/incubator-devlake/plugins/core" + "github.com/apache/incubator-devlake/plugins/core/dal" "github.com/apache/incubator-devlake/plugins/helper" "github.com/apache/incubator-devlake/plugins/jira/models" + "gorm.io/gorm" ) const RAW_ISSUE_TABLE = "jira_api_issues" @@ -58,7 +58,7 @@ func CollectIssues(taskCtx core.SubTaskContext) error { dal.Orderby("_tool_jira_issues.updated DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil { + if err != nil && err != gorm.ErrRecordNotFound { return fmt.Errorf("failed to get latest jira issue record: %w", err) } if latestUpdated.IssueId > 0 { diff --git a/plugins/tapd/tasks/bug_changelog_collector.go b/plugins/tapd/tasks/bug_changelog_collector.go index 2eb2d7cb..62dc7721 100644 --- a/plugins/tapd/tasks/bug_changelog_collector.go +++ b/plugins/tapd/tasks/bug_changelog_collector.go @@ -19,6 +19,7 @@ package tasks import ( "fmt" + "gorm.io/gorm" "net/url" "time" @@ -47,7 +48,7 @@ func CollectBugChangelogs(taskCtx core.SubTaskContext) error { dal.Orderby("created DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 8b17f30e..3e6f5c3a 100644 --- a/plugins/tapd/tasks/bug_collector.go +++ b/plugins/tapd/tasks/bug_collector.go @@ -19,6 +19,7 @@ package tasks import ( "fmt" + "gorm.io/gorm" "net/url" "time" @@ -48,7 +49,7 @@ func CollectBugs(taskCtx core.SubTaskContext) error { dal.Orderby("modified DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 5e4a7dfd..7646bc9f 100644 --- a/plugins/tapd/tasks/bug_commit_collector.go +++ b/plugins/tapd/tasks/bug_commit_collector.go @@ -20,6 +20,7 @@ package tasks import ( "encoding/json" "fmt" + "gorm.io/gorm" "net/http" "net/url" "reflect" @@ -55,7 +56,7 @@ func CollectBugCommits(taskCtx core.SubTaskContext) error { dal.Orderby("created DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 7959bc63..0c636a4b 100644 --- a/plugins/tapd/tasks/iteration_collector.go +++ b/plugins/tapd/tasks/iteration_collector.go @@ -20,6 +20,7 @@ package tasks import ( "encoding/json" "fmt" + "gorm.io/gorm" "net/http" "net/url" "time" @@ -49,7 +50,7 @@ func CollectIterations(taskCtx core.SubTaskContext) error { dal.Orderby("created DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { return fmt.Errorf("failed to get latest tapd changelog record: %w", err) } if latestUpdated.Id > 0 { diff --git a/plugins/tapd/tasks/shared.go b/plugins/tapd/tasks/shared.go index 488ba74a..3201dca7 100644 --- a/plugins/tapd/tasks/shared.go +++ b/plugins/tapd/tasks/shared.go @@ -20,6 +20,7 @@ package tasks import ( "encoding/json" "fmt" + "gorm.io/gorm" "io/ioutil" "net/http" "net/url" @@ -75,7 +76,7 @@ func parseIterationChangelog(taskCtx core.SubTaskContext, old string, new string data.Options.ConnectionId, data.Options.WorkspaceId, old), } err := db.First(iterationFrom, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { return 0, 0, err } @@ -86,7 +87,7 @@ func parseIterationChangelog(taskCtx core.SubTaskContext, old string, new string data.Options.ConnectionId, data.Options.WorkspaceId, new), } err = db.First(iterationTo, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { return 0, 0, err } return iterationFrom.Id, iterationTo.Id, nil diff --git a/plugins/tapd/tasks/story_changelog_collector.go b/plugins/tapd/tasks/story_changelog_collector.go index dd890e43..738786ce 100644 --- a/plugins/tapd/tasks/story_changelog_collector.go +++ b/plugins/tapd/tasks/story_changelog_collector.go @@ -19,13 +19,13 @@ package tasks import ( "fmt" - "net/url" - "time" - "github.com/apache/incubator-devlake/plugins/core" "github.com/apache/incubator-devlake/plugins/core/dal" "github.com/apache/incubator-devlake/plugins/helper" "github.com/apache/incubator-devlake/plugins/tapd/models" + "gorm.io/gorm" + "net/url" + "time" ) const RAW_STORY_CHANGELOG_TABLE = "tapd_api_story_changelogs" @@ -47,7 +47,7 @@ func CollectStoryChangelogs(taskCtx core.SubTaskContext) error { dal.Orderby("created DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 2c6971e5..c82414fb 100644 --- a/plugins/tapd/tasks/story_collector.go +++ b/plugins/tapd/tasks/story_collector.go @@ -19,6 +19,7 @@ package tasks import ( "fmt" + "gorm.io/gorm" "net/url" "time" @@ -47,7 +48,7 @@ func CollectStorys(taskCtx core.SubTaskContext) error { dal.Orderby("modified DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 628297f4..542e0ba6 100644 --- a/plugins/tapd/tasks/story_commit_collector.go +++ b/plugins/tapd/tasks/story_commit_collector.go @@ -20,6 +20,7 @@ package tasks import ( "encoding/json" "fmt" + "gorm.io/gorm" "net/http" "net/url" "reflect" @@ -55,7 +56,7 @@ func CollectStoryCommits(taskCtx core.SubTaskContext) error { dal.Orderby("created DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 cc464a9f..a573672c 100644 --- a/plugins/tapd/tasks/task_changelog_collector.go +++ b/plugins/tapd/tasks/task_changelog_collector.go @@ -19,6 +19,7 @@ package tasks import ( "fmt" + "gorm.io/gorm" "net/url" "time" @@ -47,7 +48,7 @@ func CollectTaskChangelogs(taskCtx core.SubTaskContext) error { dal.Orderby("created DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 338ddced..99e002a4 100644 --- a/plugins/tapd/tasks/task_collector.go +++ b/plugins/tapd/tasks/task_collector.go @@ -19,6 +19,7 @@ package tasks import ( "fmt" + "gorm.io/gorm" "net/url" "time" @@ -49,7 +50,7 @@ func CollectTasks(taskCtx core.SubTaskContext) error { dal.Orderby("modified DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 9972828a..dbf72377 100644 --- a/plugins/tapd/tasks/task_commit_collector.go +++ b/plugins/tapd/tasks/task_commit_collector.go @@ -20,6 +20,7 @@ package tasks import ( "encoding/json" "fmt" + "gorm.io/gorm" "net/http" "net/url" "reflect" @@ -55,7 +56,7 @@ func CollectTaskCommits(taskCtx core.SubTaskContext) error { dal.Orderby("created DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { 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 682a9016..ec95dfb2 100644 --- a/plugins/tapd/tasks/worklog_collector.go +++ b/plugins/tapd/tasks/worklog_collector.go @@ -19,6 +19,7 @@ package tasks import ( "fmt" + "gorm.io/gorm" "net/url" "time" @@ -47,7 +48,7 @@ func CollectWorklogs(taskCtx core.SubTaskContext) error { dal.Orderby("created DESC"), } err := db.First(&latestUpdated, clauses...) - if err != nil && err.Error() != "record not found" { + if err != nil && err != gorm.ErrRecordNotFound { return fmt.Errorf("failed to get latest tapd changelog record: %w", err) } if latestUpdated.Id > 0 {
