You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by GitBox <gi...@apache.org> on 2022/06/20 16:08:07 UTC

[GitHub] [incubator-devlake] mindlesscloud opened a new pull request, #2274: Refactor collector of worklogs and remotelinks

mindlesscloud opened a new pull request, #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274

   # Summary
   Accomplish #2273 
   
   ### Does this close any open issues?
   close #2273 
   
   
   


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] mindlesscloud commented on a diff in pull request #2274: Refactor collector of worklogs and remotelinks

Posted by GitBox <gi...@apache.org>.
mindlesscloud commented on code in PR #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274#discussion_r902116056


##########
plugins/jira/tasks/changelog_convertor.go:
##########
@@ -123,14 +118,8 @@ func ConvertChangelogs(taskCtx core.SubTaskContext) error {
 				}
 			}
 			if row.Field == "status" {
-				fromStatus, ok := statusMap[row.FromString]
-				if ok {
-					changelog.FromValue = GetStdStatus(fromStatus.StatusCategory)
-				}
-				toStatus, ok := statusMap[row.ToString]
-				if ok {
-					changelog.ToValue = GetStdStatus(toStatus.StatusCategory)
-				}
+				changelog.FromValue = getStdStatus(row.FromString)
+				changelog.ToValue = getStdStatus(row.ToString)

Review Comment:
    `GetStdStatus` and `getStdStatus` are different functions



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #2274: Refactor collector of worklogs and remotelinks

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274#discussion_r902115357


##########
plugins/jira/tasks/apiv2models/issue.go:
##########
@@ -224,26 +224,30 @@ func (i *Issue) SetAllFields(raw datatypes.JSON) error {
 	return nil
 }
 
-func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, bool, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
+func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
 	issue := i.toToolLayer(connectionId)
 	var worklogs []*models.JiraWorklog
 	var changelogs []*models.JiraChangelog
 	var changelogItems []*models.JiraChangelogItem
 	var users []*models.JiraUser
-	var needCollectWorklog bool
 	var sprints []uint64
+
 	if i.Fields.Worklog != nil {
-		if i.Fields.Worklog.Total > len(i.Fields.Worklog.Worklogs) {
-			needCollectWorklog = true
-		} else {
-			for _, w := range i.Fields.Worklog.Worklogs {
-				worklogs = append(worklogs, w.ToToolLayer(connectionId))
-			}
+		var issueUpdated *time.Time
+		if len(i.Fields.Worklog.Worklogs) <= i.Fields.Worklog.Total {
+			issueUpdated = i.Fields.Updated.ToNullableTime()
+		}
+		for _, w := range i.Fields.Worklog.Worklogs {
+			worklogs = append(worklogs, w.ToToolLayer(connectionId, issueUpdated))
 		}
 	}
 	if i.Changelog != nil {
+		var issueUpdated *time.Time
+		if len(i.Changelog.Histories) < 100 {
+			issueUpdated = i.Fields.Updated.ToNullableTime()

Review Comment:
   Because 1 page means there would not be any more records to be fetched, assigning `issueUpdated` avoid fetching records for that issue in consecutive sub-tasks.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #2274: Refactor collector of worklogs and remotelinks

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274#discussion_r902194764


##########
plugins/jira/tasks/changelog_convertor.go:
##########
@@ -123,14 +118,8 @@ func ConvertChangelogs(taskCtx core.SubTaskContext) error {
 				}
 			}
 			if row.Field == "status" {
-				fromStatus, ok := statusMap[row.FromString]
-				if ok {
-					changelog.FromValue = GetStdStatus(fromStatus.StatusCategory)
-				}
-				toStatus, ok := statusMap[row.ToString]
-				if ok {
-					changelog.ToValue = GetStdStatus(toStatus.StatusCategory)
-				}
+				changelog.FromValue = getStdStatus(row.FromString)
+				changelog.ToValue = getStdStatus(row.ToString)

Review Comment:
   why delete statusMap?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] mindlesscloud commented on a diff in pull request #2274: Refactor collector of worklogs and remotelinks

Posted by GitBox <gi...@apache.org>.
mindlesscloud commented on code in PR #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274#discussion_r902127327


##########
plugins/jira/tasks/apiv2models/issue.go:
##########
@@ -224,26 +224,30 @@ func (i *Issue) SetAllFields(raw datatypes.JSON) error {
 	return nil
 }
 
-func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, bool, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
+func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
 	issue := i.toToolLayer(connectionId)
 	var worklogs []*models.JiraWorklog
 	var changelogs []*models.JiraChangelog
 	var changelogItems []*models.JiraChangelogItem
 	var users []*models.JiraUser
-	var needCollectWorklog bool
 	var sprints []uint64
+
 	if i.Fields.Worklog != nil {
-		if i.Fields.Worklog.Total > len(i.Fields.Worklog.Worklogs) {
-			needCollectWorklog = true
-		} else {
-			for _, w := range i.Fields.Worklog.Worklogs {
-				worklogs = append(worklogs, w.ToToolLayer(connectionId))
-			}
+		var issueUpdated *time.Time
+		if len(i.Fields.Worklog.Worklogs) <= i.Fields.Worklog.Total {
+			issueUpdated = i.Fields.Updated.ToNullableTime()
+		}
+		for _, w := range i.Fields.Worklog.Worklogs {
+			worklogs = append(worklogs, w.ToToolLayer(connectionId, issueUpdated))
 		}
 	}
 	if i.Changelog != nil {
+		var issueUpdated *time.Time
+		if len(i.Changelog.Histories) < 100 {
+			issueUpdated = i.Fields.Updated.ToNullableTime()

Review Comment:
   This API only embodies 100 changelogs at most, if the number is less than 100, it means we got all changelogs of this issue. By setting `changelog.IssueUpdated = issue.Updated`, we inform the rest part of DevLake not to perform changelog collecting for this issue.



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] mindlesscloud commented on a diff in pull request #2274: Refactor collector of worklogs and remotelinks

Posted by GitBox <gi...@apache.org>.
mindlesscloud commented on code in PR #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274#discussion_r902130009


##########
plugins/jira/tasks/apiv2models/issue.go:
##########
@@ -224,26 +224,30 @@ func (i *Issue) SetAllFields(raw datatypes.JSON) error {
 	return nil
 }
 
-func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, bool, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
+func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
 	issue := i.toToolLayer(connectionId)
 	var worklogs []*models.JiraWorklog
 	var changelogs []*models.JiraChangelog
 	var changelogItems []*models.JiraChangelogItem
 	var users []*models.JiraUser
-	var needCollectWorklog bool
 	var sprints []uint64
+
 	if i.Fields.Worklog != nil {
-		if i.Fields.Worklog.Total > len(i.Fields.Worklog.Worklogs) {
-			needCollectWorklog = true

Review Comment:
   This is legacy code that should have been removed a long time ago



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] likyh commented on a diff in pull request #2274: Refactor collector of worklogs and remotelinks

Posted by GitBox <gi...@apache.org>.
likyh commented on code in PR #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274#discussion_r902096242


##########
plugins/jira/tasks/changelog_convertor.go:
##########
@@ -123,14 +118,8 @@ func ConvertChangelogs(taskCtx core.SubTaskContext) error {
 				}
 			}
 			if row.Field == "status" {
-				fromStatus, ok := statusMap[row.FromString]
-				if ok {
-					changelog.FromValue = GetStdStatus(fromStatus.StatusCategory)
-				}
-				toStatus, ok := statusMap[row.ToString]
-				if ok {
-					changelog.ToValue = GetStdStatus(toStatus.StatusCategory)
-				}
+				changelog.FromValue = getStdStatus(row.FromString)
+				changelog.ToValue = getStdStatus(row.ToString)

Review Comment:
   What is this change for?



##########
plugins/jira/tasks/apiv2models/issue.go:
##########
@@ -224,26 +224,30 @@ func (i *Issue) SetAllFields(raw datatypes.JSON) error {
 	return nil
 }
 
-func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, bool, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
+func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
 	issue := i.toToolLayer(connectionId)
 	var worklogs []*models.JiraWorklog
 	var changelogs []*models.JiraChangelog
 	var changelogItems []*models.JiraChangelogItem
 	var users []*models.JiraUser
-	var needCollectWorklog bool
 	var sprints []uint64
+
 	if i.Fields.Worklog != nil {
-		if i.Fields.Worklog.Total > len(i.Fields.Worklog.Worklogs) {
-			needCollectWorklog = true
-		} else {
-			for _, w := range i.Fields.Worklog.Worklogs {
-				worklogs = append(worklogs, w.ToToolLayer(connectionId))
-			}
+		var issueUpdated *time.Time
+		if len(i.Fields.Worklog.Worklogs) <= i.Fields.Worklog.Total {
+			issueUpdated = i.Fields.Updated.ToNullableTime()
+		}
+		for _, w := range i.Fields.Worklog.Worklogs {
+			worklogs = append(worklogs, w.ToToolLayer(connectionId, issueUpdated))
 		}
 	}
 	if i.Changelog != nil {
+		var issueUpdated *time.Time
+		if len(i.Changelog.Histories) < 100 {
+			issueUpdated = i.Fields.Updated.ToNullableTime()

Review Comment:
   Why `issueUpdated` be saved only when there is one page of Worklogs/Changelogs?



##########
plugins/jira/tasks/apiv2models/issue.go:
##########
@@ -224,26 +224,30 @@ func (i *Issue) SetAllFields(raw datatypes.JSON) error {
 	return nil
 }
 
-func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, bool, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
+func (i Issue) ExtractEntities(connectionId uint64) ([]uint64, *models.JiraIssue, []*models.JiraWorklog, []*models.JiraChangelog, []*models.JiraChangelogItem, []*models.JiraUser) {
 	issue := i.toToolLayer(connectionId)
 	var worklogs []*models.JiraWorklog
 	var changelogs []*models.JiraChangelog
 	var changelogItems []*models.JiraChangelogItem
 	var users []*models.JiraUser
-	var needCollectWorklog bool
 	var sprints []uint64
+
 	if i.Fields.Worklog != nil {
-		if i.Fields.Worklog.Total > len(i.Fields.Worklog.Worklogs) {
-			needCollectWorklog = true

Review Comment:
   `needCollectWorklog` haven't been dealt before. Why?



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh commented on a diff in pull request #2274: Refactor collector of worklogs and remotelinks

Posted by GitBox <gi...@apache.org>.
klesh commented on code in PR #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274#discussion_r902090334


##########
plugins/jira/models/migrationscripts/updateSchemas20220620.go:
##########
@@ -0,0 +1,75 @@
+/*
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+*/
+
+package migrationscripts
+
+import (
+	"context"
+	"gorm.io/gorm"
+	"time"
+)
+
+type UpdateSchemas20220620 struct {
+}
+
+type JiraIssue20220620 struct{}
+
+func (JiraIssue20220620) TableName() string {
+	return "_tool_jira_issues"
+}
+
+type JiraWorklog20220620 struct {
+	IssueUpdated *time.Time
+}
+
+func (JiraWorklog20220620) TableName() string {
+	return "_tool_jira_worklogs"
+}
+
+type JiraRemotelink20220620 struct {
+	IssueUpdated *time.Time
+}
+
+func (JiraRemotelink20220620) TableName() string {
+	return "_tool_jira_remotelinks"
+}
+
+func (*UpdateSchemas20220620) Up(ctx context.Context, db *gorm.DB) error {
+	var err error
+	err = db.Migrator().DropColumn(&JiraIssue20220620{}, "worklog_updated")
+	if err != nil {
+		return err
+	}
+	err = db.Migrator().DropColumn(&JiraIssue20220620{}, "remotelink_updated")
+	if err != nil {
+		return err
+	}
+	err = db.Migrator().AutoMigrate(&JiraWorklog20220620{}, &JiraRemotelink20220620{})

Review Comment:
   Looks like AutoMigrate for `JiraWorklog20220620` is missing



-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [incubator-devlake] klesh merged pull request #2274: Refactor collector of worklogs and remotelinks

Posted by GitBox <gi...@apache.org>.
klesh merged PR #2274:
URL: https://github.com/apache/incubator-devlake/pull/2274


-- 
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: commits-unsubscribe@devlake.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org