Skip to content

Commit

Permalink
feat: jira is subtask trans to type SUBTASK
Browse files Browse the repository at this point in the history
  • Loading branch information
abeizn committed Jun 11, 2024
1 parent 91848cd commit d667d4f
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/core/models/domainlayer/ticket/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const (
REQUIREMENT = "REQUIREMENT"
INCIDENT = "INCIDENT"
TASK = "TASK"
SUBTASK = "SUBTASK"

// status
TODO = "TODO"
Expand Down
1 change: 1 addition & 0 deletions backend/plugins/jira/models/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type JiraIssue struct {
StdType string `gorm:"type:varchar(255)"`
StdStatus string `gorm:"type:varchar(255)"`
Components string `gorm:"type:varchar(255)"`
Subtask bool
ChangelogTotal int
WorklogTotal int
common.NoPKModel
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
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 (
"github.com/apache/incubator-devlake/core/context"
"github.com/apache/incubator-devlake/core/errors"
)

type jiraIssue20240611 struct {
Subtask bool
}

func (jiraIssue20240611) TableName() string {
return "_tool_jira_issues"
}

type addSubtaskToIssue struct{}

func (script *addSubtaskToIssue) Up(basicRes context.BasicRes) errors.Error {
db := basicRes.GetDal()
err := db.AutoMigrate(&jiraIssue20240611{})
if err != nil {
return err
}
// force full issue extraction so issue.worklog_total can be updated
return db.Exec("DELETE FROM _devlake_subtask_states WHERE plugin = ? AND subtask = ?", "jira", "extractIssues")
}

func (*addSubtaskToIssue) Version() uint64 {
return 20240514145131
}

func (*addSubtaskToIssue) Name() string {
return "add subtask to _tool_jira_issues"
}
1 change: 1 addition & 0 deletions backend/plugins/jira/models/migrationscripts/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,6 @@ func All() []plugin.MigrationScript {
new(addComponents20230412),
new(addFilterJQL),
new(addWorklogToIssue),
new(addSubtaskToIssue),
}
}
3 changes: 3 additions & 0 deletions backend/plugins/jira/tasks/issue_convertor.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@ func ConvertIssues(subtaskCtx plugin.SubTaskContext) errors.Error {
if jiraIssue.ParentId != 0 {
issue.ParentIssueId = issueIdGen.Generate(data.Options.ConnectionId, jiraIssue.ParentId)
}
if jiraIssue.Subtask {
issue.Type = ticket.SUBTASK
}
result = append(result, issue)
boardIssue := &ticket.BoardIssue{
BoardId: boardId,
Expand Down
4 changes: 4 additions & 0 deletions backend/plugins/jira/tasks/issue_extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,10 @@ func extractIssues(data *JiraTaskData, mappings *typeMappings, row *api.RawData)
}
results = append(results, issueLink)
}

// is subtask
issue.Subtask = apiIssue.Fields.Issuetype.Subtask

return results, nil
}

Expand Down

0 comments on commit d667d4f

Please sign in to comment.