warren830 commented on code in PR #1968:
URL: https://github.com/apache/incubator-devlake/pull/1968#discussion_r882300851
##########
plugins/gitlab/tasks/issue_collector.go:
##########
@@ -0,0 +1,126 @@
+package tasks
+
+import (
+ "encoding/json"
+ "fmt"
+ "net/http"
+ "net/url"
+
+ "github.com/merico-dev/lake/plugins/helper"
+
+ "github.com/merico-dev/lake/plugins/core"
+ "github.com/merico-dev/lake/plugins/gitlab/models"
+)
+
+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,
+ EnabledByDefault: true,
+ Description: "Collect issues data from Gitlab api",
+}
+
+func CollectApiIssues(taskCtx core.SubTaskContext) error {
+ db := taskCtx.GetDb()
+ data := taskCtx.GetData().(*GitlabTaskData)
+
+ since := data.Since
+ incremental := false
+ // user didn't specify a time range to sync, try load from database
+ if since == nil {
+ var latestUpdated models.GitlabIssue
+ err := db.Model(&latestUpdated).
+ Where("project_id = ?", data.Options.ProjectId).
+ Order("gitlab_updated_at
DESC").Limit(1).Find(&latestUpdated).Error
+
+ if err != nil {
+ return fmt.Errorf("failed to get latest gitlab issue
record: %w", err)
+ }
+ if latestUpdated.GitlabId > 0 {
+ since = &latestUpdated.GitlabUpdatedAt
Review Comment:
yes
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]