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
jp_request = issue.jp_request
end
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
when '1. Requirement'
result[index_1].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2].push(issue.spent_hours.positive? ? issue.spent_hours : '')
result[EST_DETAIL_FIRST_COL].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[ACTUAL_TIME_DETAIL_FIRST_COL].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '2. Design'
result[index_1 + 1].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 1].push(issue.spent_hours.positive? ? issue.spent_hours : '')
result[EST_DETAIL_FIRST_COL + 1].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[ACTUAL_TIME_DETAIL_FIRST_COL + 1].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '3. Coding'
result[index_1 + 2].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 2].push(issue.spent_hours.positive? ? issue.spent_hours : '')
result[EST_DETAIL_FIRST_COL + 2].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[ACTUAL_TIME_DETAIL_FIRST_COL + 2].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '4. Testing'
result[index_1 + 3].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 3].push(issue.spent_hours.positive? ? issue.spent_hours : '')
result[EST_DETAIL_FIRST_COL + 3].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[ACTUAL_TIME_DETAIL_FIRST_COL + 3].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '5. Bug fixing'
result[index_1 + 4].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 4].push(issue.spent_hours.positive? ? issue.spent_hours : '')
result[EST_DETAIL_FIRST_COL + 4].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[ACTUAL_TIME_DETAIL_FIRST_COL + 4].push(issue.spent_hours.positive? ? issue.spent_hours : '')
when '6. Release'
result[index_1 + 5].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 5].push(issue.spent_hours.positive? ? issue.spent_hours : '')
result[EST_DETAIL_FIRST_COL + 5].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[ACTUAL_TIME_DETAIL_FIRST_COL + 5].push(issue.spent_hours.positive? ? issue.spent_hours : '')
else
result[index_1 + 6].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[index_2 + 6].push(issue.spent_hours.positive? ? issue.spent_hours : '')
result[EST_DETAIL_FIRST_COL + 6].push(issue.estimated_hours.present? ? issue.estimated_hours : '')
result[ACTUAL_TIME_DETAIL_FIRST_COL + 6].push(issue.spent_hours.positive? ? issue.spent_hours : '')
end
end
if sum_hours_record.nil?
......@@ -117,8 +115,12 @@ module WorkflowReport
result[32] << jp_request
jp_request_arr = URI(jp_request).path.split('/').reject(&:blank?)
if jp_request_arr.length == 4 && jp_request_arr[3].to_i.positive?
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 : '')
begin
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 : '')
rescue => e
result[33].push('')
end
end
else
result[32] << ''
......@@ -138,14 +140,16 @@ module WorkflowReport
pr_link_arr = URI(link.strip).path.split('/').compact_blank
next unless pr_link_arr.length == 4
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?
pr_comments += pr_detail.comments
pr_review_comments += pr_detail.review_comments
pr_commits += pr_detail.commits
pr_additions += pr_detail.additions
pr_deletions += pr_detail.deletions
pr_changed_files += pr_detail.changed_files
begin
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?
pr_comments += pr_detail.comments
pr_review_comments += pr_detail.review_comments
pr_commits += pr_detail.commits
pr_additions += pr_detail.additions
pr_deletions += pr_detail.deletions
pr_changed_files += pr_detail.changed_files
end
end
result[34] << pr_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