warren830 commented on code in PR #3711:
URL: 
https://github.com/apache/incubator-devlake/pull/3711#discussion_r1018709791


##########
plugins/tapd/tasks/story_bug_collector.go:
##########
@@ -42,52 +38,33 @@ func CollectStoryBugs(taskCtx core.SubTaskContext) 
errors.Error {
        logger := taskCtx.GetLogger()
        logger.Info("collect storyBugs")
        since := data.Since
-       incremental := false
-       if since == nil {
-               // user didn't specify a time range to sync, try load from 
database
-               var latestUpdated models.TapdStoryCommit
-               clauses := []dal.Clause{
-                       dal.Where("connection_id = ? and workspace_id = ?", 
data.Options.ConnectionId, data.Options.WorkspaceId),
-                       dal.Orderby("created DESC"),
-               }
-               err := db.First(&latestUpdated, clauses...)
-               if err != nil && !goerror.Is(err, gorm.ErrRecordNotFound) {
-                       return errors.NotFound.Wrap(err, "failed to get latest 
tapd changelog record")
-               }
-               if latestUpdated.Id > 0 {
-                       since = (*time.Time)(latestUpdated.Created)
-                       incremental = true
-               }
-       }
-
        clauses := []dal.Clause{
-               dal.Select("id"),
+               dal.Select("id as issue_id, modified as update_time"),
                dal.From(&models.TapdStory{}),
-               dal.Where("connection_id = ? and workspace_id = ?", 
data.Options.ConnectionId, data.Options.WorkspaceId),
+               dal.Where("_tool_tapd_stories.connection_id = ? and 
_tool_tapd_stories.workspace_id = ? ", data.Options.ConnectionId, 
data.Options.WorkspaceId),
        }
        if since != nil {
                clauses = append(clauses, dal.Where("modified > ?", since))
        }
-
        cursor, err := db.Cursor(clauses...)
        if err != nil {
                return err
        }
-       iterator, err := helper.NewDalCursorIterator(db, cursor, 
reflect.TypeOf(SimpleStory{}))
+       iterator, err := helper.NewDalCursorIterator(db, cursor, 
reflect.TypeOf(models.Input{}))
        if err != nil {
                return err
        }
        collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{
                RawDataSubTaskArgs: *rawDataSubTaskArgs,
                ApiClient:          data.ApiClient,
-               Incremental:        incremental,
+               Incremental:        since == nil,

Review Comment:
   fixed



##########
plugins/tapd/tasks/bug_commit_collector.go:
##########
@@ -77,24 +52,24 @@ func CollectBugCommits(taskCtx core.SubTaskContext) 
errors.Error {
        if err != nil {
                return err
        }
-       iterator, err := helper.NewDalCursorIterator(db, cursor, 
reflect.TypeOf(SimpleBug{}))
+       iterator, err := helper.NewDalCursorIterator(db, cursor, 
reflect.TypeOf(models.Input{}))
 
        if err != nil {
                return err
        }
        collector, err := helper.NewApiCollector(helper.ApiCollectorArgs{
                RawDataSubTaskArgs: *rawDataSubTaskArgs,
-               Incremental:        incremental,
+               Incremental:        since == nil,

Review Comment:
   fixed



-- 
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]

Reply via email to