Skip to content

Commit 19d210d

Browse files
committed
feat: #72 desc, date and StoryPoint
1 parent 53954cf commit 19d210d

File tree

3 files changed

+36
-15
lines changed

3 files changed

+36
-15
lines changed

Diff for: app/Commands/IssueImportCommand.php

+27-4
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function handle(Issue $codingIssue, Project $codingProject, Iteration $it
7070
return 0;
7171
}
7272

73-
private function createIssueByRow(Project $codingProject, Issue $issue, Iteration $iteration, array $row)
73+
private function getIssueTypes(Project $codingProject, $row): void
7474
{
7575
if (empty($this->issueTypes)) {
7676
$result = $codingProject->getIssueTypes($this->codingToken, $this->codingProjectUri);
@@ -81,14 +81,37 @@ private function createIssueByRow(Project $codingProject, Issue $issue, Iteratio
8181
if (!isset($this->issueTypes[$row['事项类型']])) {
8282
throw new Exception('' . $row['事项类型'] . '」类型不存在,请在项目设置中添加');
8383
}
84+
}
85+
86+
private function createIssueByRow(Project $codingProject, Issue $issue, Iteration $iteration, array $row)
87+
{
88+
$this->getIssueTypes($codingProject, $row);
8489
$data = [
8590
'Type' => $this->issueTypes[$row['事项类型']]['IssueType'],
8691
'IssueTypeId' => $this->issueTypes[$row['事项类型']]['Id'],
8792
'Name' => $row['标题'],
88-
'Priority' => \App\Models\Issue::PRIORITY_MAP[$row['优先级']],
89-
'IterationCode' => $row['所属迭代'] ? $this->getIterationCode($iteration, $row['所属迭代']) : null,
90-
'ParentCode' => !empty($row['ParentCode']) ? $this->issueCodeMap[$row['ParentCode']] : null,
9193
];
94+
if (!empty($row['优先级'])) {
95+
$data['Priority'] = \App\Models\Issue::PRIORITY_MAP[$row['优先级']];
96+
}
97+
if (!empty($row['所属迭代'])) {
98+
$data['IterationCode'] = $this->getIterationCode($iteration, $row['所属迭代']);
99+
}
100+
if (!empty($row['ParentCode'])) {
101+
$data['ParentCode'] = $this->issueCodeMap[$row['ParentCode']];
102+
}
103+
foreach (
104+
[
105+
'Description' => '描述',
106+
'DueDate' => '截止日期',
107+
'StartDate' => '开始日期',
108+
'StoryPoint' => '故事点',
109+
] as $english => $chinese
110+
) {
111+
if (!empty($row[$chinese])) {
112+
$data[$english] = $row[$chinese];
113+
}
114+
}
92115
$result = $issue->create($this->codingToken, $this->codingProjectUri, $data);
93116
if (isset($row['ID'])) {
94117
$this->issueCodeMap[$row['ID']] = intval($result['Code']);

Diff for: tests/Feature/IssueImportCommandTest.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,8 @@ public function testImportUserStorySuccess()
9999
'Name' => '用户可通过手机号注册账户',
100100
'Priority' => "1",
101101
'IterationCode' => 2746,
102-
'ParentCode' => null,
102+
'DueDate' => '2021-10-21',
103+
'StoryPoint' => '2',
103104
]
104105
])->andReturn($result);
105106

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

@@ -151,8 +151,7 @@ public function testImportSubTask()
151151
'Type' => 'SUB_TASK',
152152
'IssueTypeId' => 213222,
153153
'Name' => '完成手机号注册的短信验证码发送接口',
154-
'Priority' => "1",
155-
'IterationCode' => null,
154+
'Priority' => "0",
156155
'ParentCode' => 2742,
157156
]
158157
])->andReturn($subTask1);
@@ -167,7 +166,6 @@ public function testImportSubTask()
167166
'IssueTypeId' => 213222,
168167
'Name' => '完成通过手机号注册用户的接口',
169168
'Priority' => "1",
170-
'IterationCode' => null,
171169
'ParentCode' => 2742,
172170
]
173171
])->andReturn($subTask2);

Diff for: tests/data/coding/scrum-issues-5-6-7.csv

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ID,ParentCode,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
2-
7,5,子工作项,完成通过手机号注册用户的接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,中,,,,,
3-
6,5,子工作项,完成手机号注册的短信验证码发送接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,,,,,,
4-
5,,用户故事,用户可通过手机号注册账户,,开发中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,2,sinkcup,,,2021-10-21,,,,
1+
ID,ParentCode,事项类型,标题,描述,状态,创建时间,创建人,更新时间,所属迭代,故事点,处理人,缺陷类型,优先级,截止日期,模块,标签,关注人,开始日期
2+
7,5,子工作项,完成通过手机号注册用户的接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,中,,,,,
3+
6,5,子工作项,完成手机号注册的短信验证码发送接口,,已完成,2021-10-19 11:26:38,sinkcup,2021-10-19 11:26:38,,,,,,,,,,
4+
5,,用户故事,用户可通过手机号注册账户,,开发中,2021-10-19 11:26:37,sinkcup,2021-10-19 11:26:37,,2,sinkcup,,,2021-10-21,,,,

0 commit comments

Comments
 (0)