d4x1 commented on code in PR #8316:
URL:
https://github.com/apache/incubator-devlake/pull/8316#discussion_r1982662816
##########
backend/core/models/common/iso8601time.go:
##########
@@ -138,6 +142,16 @@ func ConvertStringToTime(timeString string) (t time.Time,
err error) {
return time.Parse(time.RFC3339, timeString)
}
+// ConvertStringToTimeInTz
Review Comment:
The comment dismatch the function signature.
##########
backend/plugins/jira/tasks/issue_extractor.go:
##########
@@ -143,7 +145,39 @@ func extractIssues(data *JiraTaskData, mappings
*typeMappings, apiIssue *apiv2mo
}
}
-
+ // default due date field is "duedate"
+ dueDateField := "duedate"
+ if data.Options.ScopeConfig != nil &&
data.Options.ScopeConfig.DueDateField != "" {
+ dueDateField = data.Options.ScopeConfig.DueDateField
+ }
+ unknownDueDate := apiIssue.Fields.AllFields[dueDateField]
+ switch dd := unknownDueDate.(type) {
+ case string:
+ // string, try to parse
+ if dd == "" || dd == "null" {
+ break
+ }
+ // use loc of issue.Created if dd is of type date (yyyy-MM-dd)
+ isDateStr, _ := regexp.Match(`\d{4}-\d{2}-\d{2}`, []byte(dd))
+ var temp time.Time
+ if isDateStr {
+ temp, _ = common.ConvertStringToTimeInLoc(dd,
issue.Created.Location())
+ } else {
+ temp, _ = common.ConvertStringToTime(dd)
Review Comment:
I think `isDateStr` deserves a better name, maybe `isDateStrWithoutLocation`?
##########
backend/plugins/tapd/tasks/bug_extractor.go:
##########
@@ -77,6 +88,29 @@ func ExtractBugs(taskCtx plugin.SubTaskContext) errors.Error
{
if strings.Contains(toolL.CurrentOwner, ";") {
toolL.CurrentOwner =
strings.Split(toolL.CurrentOwner, ";")[0]
}
+ value := toolL.AllFields[dueDateField]
Review Comment:
Similiar to above.
##########
backend/plugins/jira/tasks/issue_extractor.go:
##########
@@ -143,7 +145,39 @@ func extractIssues(data *JiraTaskData, mappings
*typeMappings, apiIssue *apiv2mo
}
}
-
+ // default due date field is "duedate"
+ dueDateField := "duedate"
+ if data.Options.ScopeConfig != nil &&
data.Options.ScopeConfig.DueDateField != "" {
+ dueDateField = data.Options.ScopeConfig.DueDateField
+ }
+ unknownDueDate := apiIssue.Fields.AllFields[dueDateField]
Review Comment:
Advice: use `if v, ok:=map[key]` can reduce the branch `case nil`.
--
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]