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
def export
team = params[:team]
project_ids = $workflow_report_config['teams'].select { |hash| hash.key?(team) }[0][team]
result = Rails.cache.fetch("#{team}_#{params[:year]}_#{params[:month]}", expires_in: 1.hours) do
project_ids = if team == 'All-team'
$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)
end
......
......@@ -10,6 +10,6 @@ class WorkflowReportIssue < Issue
.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 ?))',
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
......@@ -119,7 +119,6 @@ p.error_link {
td.notes {
position: relative;
cursor: pointer;
}
.note_est {
......@@ -127,6 +126,7 @@ td.notes {
}
.over_text {
cursor: pointer;
overflow: hidden;
display: block;
display: -webkit-box;
......@@ -135,6 +135,7 @@ td.notes {
}
.over_text::before {
cursor: pointer;
position: absolute;
right: 6px;
top: 8px;
......
......@@ -42,3 +42,4 @@ teams:
- 146
- APW-SUB:
- 137
- All-team:
......@@ -12,6 +12,7 @@ module WorkflowReport
COL_REQUIREMENT_TO_RELEASE = 6
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
QUANTITY_THREAD = 10
class << self
def build_report(year, month, project_ids)
......@@ -100,20 +101,23 @@ module WorkflowReport
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
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
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
threads_issue.each(&:join)
threads_pr.each(&:join)
thread_pool.each(&:join)
{ workflow_report: result, error_links: error_links }
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