Commit 78842d2e by Tấn Trần Thanh

build report all team

parent cdd50b9a
Pipeline #1615 failed with stages
in 0 seconds
...@@ -44,8 +44,13 @@ class WorkflowReportController < ApplicationController ...@@ -44,8 +44,13 @@ class WorkflowReportController < ApplicationController
def export def export
team = params[:team] team = params[:team]
project_ids = $workflow_report_config['teams'].select { |hash| hash.key?(team) }[0][team] project_ids = if team == 'All-team'
result = Rails.cache.fetch("#{team}_#{params[:year]}_#{params[:month]}", expires_in: 1.hours) do $workflow_report_config['teams'].map(&:values).flatten.compact
else
$workflow_report_config['teams'].find { |hash| hash.key?(team) }[team]
end
result = Rails.cache.fetch("#{team}_#{params[:year]}_#{params[:month]}", expires_in: team == 'All-team' ? 1.hours : 1.days) do
WorkflowReport.build_report(params[:year].to_i, params[:month].to_i, project_ids) WorkflowReport.build_report(params[:year].to_i, params[:month].to_i, project_ids)
end end
......
...@@ -10,6 +10,6 @@ class WorkflowReportIssue < Issue ...@@ -10,6 +10,6 @@ class WorkflowReportIssue < Issue
.where(projects: { id: project_ids }, enabled_modules: { name: 'time_tracking' }) .where(projects: { id: project_ids }, enabled_modules: { name: 'time_tracking' })
.where(['((time_entries.spent_on IS NOT NULL AND time_entries.tyear = ? AND time_entries.tmonth = ?) OR (issues.closed_on BETWEEN ? AND ?))', .where(['((time_entries.spent_on IS NOT NULL AND time_entries.tyear = ? AND time_entries.tmonth = ?) OR (issues.closed_on BETWEEN ? AND ?))',
year, month, DateTime.new(year, month).beginning_of_day, DateTime.new(year, month, -1).end_of_day]) year, month, DateTime.new(year, month).beginning_of_day, DateTime.new(year, month, -1).end_of_day])
.order(:root_id) .order(Arel.sql("FIELD(projects.id, #{project_ids.join(',')})"), :root_id)
} }
end end
...@@ -119,7 +119,6 @@ p.error_link { ...@@ -119,7 +119,6 @@ p.error_link {
td.notes { td.notes {
position: relative; position: relative;
cursor: pointer;
} }
.note_est { .note_est {
...@@ -127,6 +126,7 @@ td.notes { ...@@ -127,6 +126,7 @@ td.notes {
} }
.over_text { .over_text {
cursor: pointer;
overflow: hidden; overflow: hidden;
display: block; display: block;
display: -webkit-box; display: -webkit-box;
...@@ -135,6 +135,7 @@ td.notes { ...@@ -135,6 +135,7 @@ td.notes {
} }
.over_text::before { .over_text::before {
cursor: pointer;
position: absolute; position: absolute;
right: 6px; right: 6px;
top: 8px; top: 8px;
......
...@@ -42,3 +42,4 @@ teams: ...@@ -42,3 +42,4 @@ teams:
- 146 - 146
- APW-SUB: - APW-SUB:
- 137 - 137
- All-team:
...@@ -12,6 +12,7 @@ module WorkflowReport ...@@ -12,6 +12,7 @@ module WorkflowReport
COL_REQUIREMENT_TO_RELEASE = 6 COL_REQUIREMENT_TO_RELEASE = 6
PROCESS = ['1. Requirement', '2. Design', '3. Coding', '4. Testing', '5. Bug fixing', '6. Release', ''].freeze PROCESS = ['1. Requirement', '2. Design', '3. Coding', '4. Testing', '5. Bug fixing', '6. Release', ''].freeze
BUGS = { testcases: 22, bugs: 23, stg_bugs: 27, prod_bugs: 28 }.freeze BUGS = { testcases: 22, bugs: 23, stg_bugs: 27, prod_bugs: 28 }.freeze
QUANTITY_THREAD = 10
class << self class << self
def build_report(year, month, project_ids) def build_report(year, month, project_ids)
...@@ -100,20 +101,23 @@ module WorkflowReport ...@@ -100,20 +101,23 @@ module WorkflowReport
end end
end end
threads_pr = github_links[:prs].map do |prs| 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 Thread.new do
find_detail_pr(github, prs[:links], error_links, result, prs[:row], prs[:root_id]) until work_queue.empty?
type, item = work_queue.pop(true) rescue nil
if type == :pr
find_detail_pr(github, item[:links], error_links, result, item[:row], item[:root_id])
elsif type == :issue
find_detail_issue(github, result, error_links, item[:links], item[:row], item[:root_id])
end end
end end
threads_issue = github_links[:issues].map do |issues|
Thread.new do
find_detail_issue(github, result, error_links, issues[:links], issues[:row], issues[:root_id])
end end
end end
thread_pool.each(&:join)
threads_issue.each(&:join)
threads_pr.each(&:join)
{ workflow_report: result, error_links: error_links } { workflow_report: result, error_links: error_links }
end end
......
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