Commit b5eef676 by Tấn Trần Thanh

REDMINE cover case github token did not access to repo

parent aa117c95
Pipeline #1587 failed with stages
in 0 seconds
...@@ -66,31 +66,29 @@ module WorkflowReport ...@@ -66,31 +66,29 @@ module WorkflowReport
jp_request = issue.jp_request jp_request = issue.jp_request
end end
process = get_process(issue.subject.gsub(/[^[:print:]]/, '')) process = get_process(issue.subject.gsub(/[^[:print:]]/, ''))
index_1 = EST_DETAIL_FIRST_COL # first index for estimation detail
index_2 = ACTUAL_TIME_DETAIL_FIRST_COL # first index for actual detail
case process case process
when '1. Requirement' when '1. Requirement'
result[index_1].push(issue.estimated_hours.present? ? issue.estimated_hours : '') result[EST_DETAIL_FIRST_COL].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2].push(issue.spent_hours.positive? ? issue.spent_hours : '') result[ACTUAL_TIME_DETAIL_FIRST_COL].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '2. Design' when '2. Design'
result[index_1 + 1].push(issue.estimated_hours.present? ? issue.estimated_hours : '') result[EST_DETAIL_FIRST_COL + 1].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 1].push(issue.spent_hours.positive? ? issue.spent_hours : '') result[ACTUAL_TIME_DETAIL_FIRST_COL + 1].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '3. Coding' when '3. Coding'
result[index_1 + 2].push(issue.estimated_hours.present? ? issue.estimated_hours : '') result[EST_DETAIL_FIRST_COL + 2].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 2].push(issue.spent_hours.positive? ? issue.spent_hours : '') result[ACTUAL_TIME_DETAIL_FIRST_COL + 2].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '4. Testing' when '4. Testing'
result[index_1 + 3].push(issue.estimated_hours.present? ? issue.estimated_hours : '') result[EST_DETAIL_FIRST_COL + 3].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 3].push(issue.spent_hours.positive? ? issue.spent_hours : '') result[ACTUAL_TIME_DETAIL_FIRST_COL + 3].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '5. Bug fixing' when '5. Bug fixing'
result[index_1 + 4].push(issue.estimated_hours.present? ? issue.estimated_hours : '') result[EST_DETAIL_FIRST_COL + 4].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 4].push(issue.spent_hours.positive? ? issue.spent_hours : '') result[ACTUAL_TIME_DETAIL_FIRST_COL + 4].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '6. Release' when '6. Release'
result[index_1 + 5].push(issue.estimated_hours.present? ? issue.estimated_hours : '') result[EST_DETAIL_FIRST_COL + 5].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 5].push(issue.spent_hours.positive? ? issue.spent_hours : '') result[ACTUAL_TIME_DETAIL_FIRST_COL + 5].push(issue.spent_hours.positive? ? issue.spent_hours : '')
else else
result[index_1 + 6].push(issue.estimated_hours.present? ? issue.estimated_hours : '') result[EST_DETAIL_FIRST_COL + 6].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 6].push(issue.spent_hours.positive? ? issue.spent_hours : '') result[ACTUAL_TIME_DETAIL_FIRST_COL + 6].push(issue.spent_hours.positive? ? issue.spent_hours : '')
end end
end end
if sum_hours_record.nil? if sum_hours_record.nil?
...@@ -117,8 +115,12 @@ module WorkflowReport ...@@ -117,8 +115,12 @@ module WorkflowReport
result[32] << jp_request result[32] << jp_request
jp_request_arr = URI(jp_request).path.split('/').reject(&:blank?) jp_request_arr = URI(jp_request).path.split('/').reject(&:blank?)
if jp_request_arr.length == 4 && jp_request_arr[3].to_i.positive? if jp_request_arr.length == 4 && jp_request_arr[3].to_i.positive?
begin
issue_detail = github.issues.find user: jp_request_arr[0], repo: jp_request_arr[1], number: jp_request_arr[3] issue_detail = github.issues.find user: jp_request_arr[0], repo: jp_request_arr[1], number: jp_request_arr[3]
result[33].push(issue_detail.success? ? issue_detail.comments : '') result[33].push(issue_detail.success? ? issue_detail.comments : '')
rescue => e
result[33].push('')
end
end end
else else
result[32] << '' result[32] << ''
...@@ -138,6 +140,7 @@ module WorkflowReport ...@@ -138,6 +140,7 @@ module WorkflowReport
pr_link_arr = URI(link.strip).path.split('/').compact_blank pr_link_arr = URI(link.strip).path.split('/').compact_blank
next unless pr_link_arr.length == 4 next unless pr_link_arr.length == 4
begin
pr_detail = github.pull_requests.find user: pr_link_arr[0], repo: pr_link_arr[1], number: pr_link_arr[3] pr_detail = github.pull_requests.find user: pr_link_arr[0], repo: pr_link_arr[1], number: pr_link_arr[3]
if pr_detail.success? if pr_detail.success?
pr_comments += pr_detail.comments pr_comments += pr_detail.comments
...@@ -147,6 +150,7 @@ module WorkflowReport ...@@ -147,6 +150,7 @@ module WorkflowReport
pr_deletions += pr_detail.deletions pr_deletions += pr_detail.deletions
pr_changed_files += pr_detail.changed_files pr_changed_files += pr_detail.changed_files
end end
end
result[34] << pr_comments result[34] << pr_comments
result[35] << pr_review_comments result[35] << pr_review_comments
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment