Skip to content

Commit

Permalink
feat: #72 desc, date and StoryPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sinkcup committed Oct 22, 2021
1 parent 53954cf commit 19d210d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 15 deletions.
31 changes: 27 additions & 4 deletions app/Commands/IssueImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function handle(Issue $codingIssue, Project $codingProject, Iteration $it
return 0;
}

private function createIssueByRow(Project $codingProject, Issue $issue, Iteration $iteration, array $row)
private function getIssueTypes(Project $codingProject, $row): void
{
if (empty($this->issueTypes)) {
$result = $codingProject->getIssueTypes($this->codingToken, $this->codingProjectUri);
Expand All @@ -81,14 +81,37 @@ private function createIssueByRow(Project $codingProject, Issue $issue, Iteratio
if (!isset($this->issueTypes[$row['事项类型']])) {
throw new Exception('' . $row['事项类型'] . '」类型不存在,请在项目设置中添加');
}
}

private function createIssueByRow(Project $codingProject, Issue $issue, Iteration $iteration, array $row)
{
$this->getIssueTypes($codingProject, $row);
$data = [
'Type' => $this->issueTypes[$row['事项类型']]['IssueType'],
'IssueTypeId' => $this->issueTypes[$row['事项类型']]['Id'],
'Name' => $row['标题'],
'Priority' => \App\Models\Issue::PRIORITY_MAP[$row['优先级']],
'IterationCode' => $row['所属迭代'] ? $this->getIterationCode($iteration, $row['所属迭代']) : null,
'ParentCode' => !empty($row['ParentCode']) ? $this->issueCodeMap[$row['ParentCode']] : null,
];
if (!empty($row['优先级'])) {
$data['Priority'] = \App\Models\Issue::PRIORITY_MAP[$row['优先级']];
}
if (!empty($row['所属迭代'])) {
$data['IterationCode'] = $this->getIterationCode($iteration, $row['所属迭代']);
}
if (!empty($row['ParentCode'])) {
$data['ParentCode'] = $this->issueCodeMap[$row['ParentCode']];
}
foreach (
[
'Description' => '描述',
'DueDate' => '截止日期',
'StartDate' => '开始日期',
'StoryPoint' => '故事点',
] as $english => $chinese
) {
if (!empty($row[$chinese])) {
$data[$english] = $row[$chinese];
}
}
$result = $issue->create($this->codingToken, $this->codingProjectUri, $data);
if (isset($row['ID'])) {
$this->issueCodeMap[$row['ID']] = intval($result['Code']);
Expand Down
12 changes: 5 additions & 7 deletions tests/Feature/IssueImportCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ public function testImportUserStorySuccess()
'Name' => '用户可通过手机号注册账户',
'Priority' => "1",
'IterationCode' => 2746,
'ParentCode' => null,
'DueDate' => '2021-10-21',
'StoryPoint' => '2',
]
])->andReturn($result);

Expand Down Expand Up @@ -136,9 +137,8 @@ public function testImportSubTask()
'Type' => 'REQUIREMENT',
'IssueTypeId' => 213218,
'Name' => '用户可通过手机号注册账户',
'Priority' => "1",
'IterationCode' => null,
'ParentCode' => null,
'DueDate' => '2021-10-21',
'StoryPoint' => '2',
]
])->andReturn($parentIssue);

Expand All @@ -151,8 +151,7 @@ public function testImportSubTask()
'Type' => 'SUB_TASK',
'IssueTypeId' => 213222,
'Name' => '完成手机号注册的短信验证码发送接口',
'Priority' => "1",
'IterationCode' => null,
'Priority' => "0",
'ParentCode' => 2742,
]
])->andReturn($subTask1);
Expand All @@ -167,7 +166,6 @@ public function testImportSubTask()
'IssueTypeId' => 213222,
'Name' => '完成通过手机号注册用户的接口',
'Priority' => "1",
'IterationCode' => null,
'ParentCode' => 2742,
]
])->andReturn($subTask2);
Expand Down
8 changes: 4 additions & 4 deletions tests/data/coding/scrum-issues-5-6-7.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ID,ParentCode,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
7,5,子工作项,完成通过手机号注册用户的接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,中,,,,,
6,5,子工作项,完成手机号注册的短信验证码发送接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,,,,,,
5,,用户故事,用户可通过手机号注册账户,,开发中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,2,sinkcup,,,2021-10-21,,,,
ID,ParentCode,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
7,5,子工作项,完成通过手机号注册用户的接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,中,,,,,
6,5,子工作项,完成手机号注册的短信验证码发送接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,,,,,,
5,,用户故事,用户可通过手机号注册账户,,开发中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,2,sinkcup,,,2021-10-21,,,,

0 comments on commit 19d210d

Please sign in to comment.