Commit 9d0bc2a6 by Tấn Trần Thanh

refactor code

parent 78842d2e
Pipeline #1616 failed with stages
in 0 seconds
......@@ -18,7 +18,7 @@ module WorkflowReport
def build_report(year, month, project_ids)
github = Github.new oauth_token: $workflow_report_config['github_token']
error_links = []
github_links = { prs: [], issues: [] }
work_queue = Queue.new
result = TABLE_HEADER.length.times.map { [] }
raw_tasks = WorkflowReportIssue.raw_tasks_records(year, month, project_ids)
return { workflow_report: [], error_links: [] } if raw_tasks.empty?
......@@ -67,8 +67,8 @@ module WorkflowReport
if issue.tracker_id == USER_STORY_TRACKER_ID
pr_links = issue.custom_values.find_by(custom_field_id: PR_FIELD_ID)&.value
jp_request = issue.custom_values.find_by(custom_field_id: JP_REQUEST_FIELD_ID)&.value
github_links[:prs].push({ row: result[0].length - 1, links: pr_links, root_id: root_id }) if pr_links.present?
github_links[:issues].push({ row: result[0].length - 1, links: jp_request, root_id: root_id }) if jp_request.present?
work_queue.push([:pr, { row: result[0].length - 1, links: pr_links, root_id: root_id }]) if pr_links.present?
work_queue.push([:issue, { row: result[0].length - 1, links: jp_request, root_id: root_id }]) if jp_request.present?
end
process = get_process(issue.subject.gsub(/[^[:print:]]/, ''))
......@@ -101,10 +101,6 @@ module WorkflowReport
end
end
work_queue = Queue.new
github_links[:prs].each { |prs| work_queue.push([:pr, prs]) }
github_links[:issues].each { |issues| work_queue.push([:issue, issues]) }
thread_pool = Array.new(QUANTITY_THREAD) do
Thread.new do
until work_queue.empty?
......
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