fix
This commit is contained in:
parent
efef195c27
commit
3505d29410
|
@ -55,10 +55,8 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
|
||||||
def polyline
|
def polyline
|
||||||
return tip_exception '参数错误' if params[:pm_project_id].blank?
|
return tip_exception '参数错误' if params[:pm_project_id].blank?
|
||||||
time_line = (Time.current.beginning_of_day - 6.day) .. Time.current
|
time_line = (Time.current.beginning_of_day - 6.day) .. Time.current
|
||||||
# @create_issues = Issue.where(pm_project_id: params[:pm_project_id],created_on: time_line)
|
@create_issues = Issue.where(pm_project_id: params[:pm_project_id],created_on: time_line)
|
||||||
# @due_issues = Issue.where(pm_project_id: params[:pm_project_id],due_date: time_line)
|
@due_issues = Issue.where(pm_project_id: params[:pm_project_id],due_date: time_line)
|
||||||
@create_issues = Issue.where(pm_project_id: 135,created_on: time_line)
|
|
||||||
@due_issues = Issue.where(pm_project_id: 135,due_date: time_line)
|
|
||||||
@create_issues_count = @create_issues.group(:pm_issue_type,"DATE(created_on)").count
|
@create_issues_count = @create_issues.group(:pm_issue_type,"DATE(created_on)").count
|
||||||
@due_issues_count = @due_issues.group(:pm_issue_type,"DATE(due_date)").count
|
@due_issues_count = @due_issues.group(:pm_issue_type,"DATE(due_date)").count
|
||||||
data = {
|
data = {
|
||||||
|
@ -67,17 +65,20 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
|
||||||
}
|
}
|
||||||
7.times do |time|
|
7.times do |time|
|
||||||
current_time = Date.current - time.day
|
current_time = Date.current - time.day
|
||||||
data[:create_issues][current_time] = {
|
if @create_issues_count.present?
|
||||||
"1": @create_issues_count[[1,current_time]] || 0,
|
data[:create_issues][current_time] = {
|
||||||
"2": @create_issues_count[[2,current_time]] || 0,
|
"1": @create_issues_count[[1,current_time]] || 0,
|
||||||
"3": @create_issues_count[[3,current_time]] || 0
|
"2": @create_issues_count[[2,current_time]] || 0,
|
||||||
}
|
"3": @create_issues_count[[3,current_time]] || 0
|
||||||
|
}
|
||||||
data[:due_issues][current_time] = {
|
end
|
||||||
"1": @due_issues_count[[1,current_time]] || 0,
|
if @due_issues_count.present?
|
||||||
"2": @due_issues_count[[2,current_time]] || 0,
|
data[:due_issues][current_time] = {
|
||||||
"3": @due_issues_count[[3,current_time]] || 0
|
"1": @due_issues_count[[1,current_time]] || 0,
|
||||||
}
|
"2": @due_issues_count[[2,current_time]] || 0,
|
||||||
|
"3": @due_issues_count[[3,current_time]] || 0
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
render_ok(data: data)
|
render_ok(data: data)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,29 +2,27 @@ class Api::Pm::SprintIssuesController < Api::Pm::BaseController
|
||||||
|
|
||||||
before_action :require_login, except: [:index]
|
before_action :require_login, except: [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@issues = Api::Pm::SprintIssues::ListService.call(query_params, current_user)
|
@issues = Api::Pm::SprintIssues::ListService.call(query_params, current_user)
|
||||||
@issues = kaminari_paginate(@issues)
|
@issues = kaminari_paginate(@issues)
|
||||||
render 'api/v1/issues/index'
|
render 'api/v1/issues/index'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def burndown_charts
|
def burndown_charts
|
||||||
return tip_exception '参数错误' if params[:pm_sprint_id].blank? || params[:start_time].blank? || params[:end_time].blank?
|
return tip_exception '参数错误' if params[:pm_sprint_id].blank? || params[:start_time].blank? || params[:end_time].blank?
|
||||||
@issues = Issue.where(pm_sprint_id: params[:pm_sprint_id])
|
@issues = Issue.where(pm_sprint_id: params[:pm_sprint_id])
|
||||||
start_time = Date.parse params[:start_time]
|
start_time = Date.parse params[:start_time]
|
||||||
end_time = Date.parse params[:end_time]
|
end_time = Date.parse params[:end_time]
|
||||||
time_count = (end_time - start_time).to_i + 1 #计算间隔时间 加上最后一天
|
time_count = (end_time - start_time).to_i + 1 # 计算间隔时间 加上最后一天
|
||||||
data = []
|
data = []
|
||||||
curren_issues = @issues.group(:status_id,:due_date).count
|
curren_issues = @issues.group(:status_id, :due_date).count
|
||||||
total_count = @issues.count
|
total_count = @issues.count
|
||||||
cardinality = BigDecimal.new(total_count) / BigDecimal.new(time_count)
|
cardinality = BigDecimal.new(total_count) / BigDecimal.new(time_count)
|
||||||
time_count.times do |x|
|
time_count.times do |x|
|
||||||
e_time = start_time + x
|
e_time = start_time + x
|
||||||
completed = curren_issues[[5,e_time]].to_i + curren_issues[[3, e_time]].to_i - @issues.where(pm_issue_type: 3, status_id: 3).size
|
completed = curren_issues[[5, e_time]].to_i + curren_issues[[3, e_time]].to_i - @issues.where(pm_issue_type: 3, status_id: 3).size
|
||||||
total_count = total_count - completed
|
total_count = total_count - completed
|
||||||
data << {time: e_time, undone: total_count, completed:completed, base_number: (cardinality * (time_count - x - 1)).to_f.round(2)}
|
data << { time: e_time, undone: total_count, completed: completed, base_number: (cardinality * (time_count - x - 1)).to_f.round(2) }
|
||||||
end
|
end
|
||||||
render_ok(data: data)
|
render_ok(data: data)
|
||||||
end
|
end
|
||||||
|
@ -41,11 +39,12 @@ class Api::Pm::SprintIssuesController < Api::Pm::BaseController
|
||||||
@issues_hour_count = @issues.group(:pm_sprint_id).sum(:time_scale)
|
@issues_hour_count = @issues.group(:pm_sprint_id).sum(:time_scale)
|
||||||
@issues_hour_type_count = @issues.group(:pm_sprint_id, :status_id).sum(:time_scale)
|
@issues_hour_type_count = @issues.group(:pm_sprint_id, :status_id).sum(:time_scale)
|
||||||
@issues_hour_pm_type_count = @issues.group(:pm_sprint_id, :pm_issue_type).sum(:time_scale)
|
@issues_hour_pm_type_count = @issues.group(:pm_sprint_id, :pm_issue_type).sum(:time_scale)
|
||||||
|
@issues_status_pm_type_count = @issues.group(:pm_sprint_id, :pm_issue_type, :status_id).sum(:time_scale)
|
||||||
pm_sprint_ids.map(&:to_i).map do |sprint_id|
|
pm_sprint_ids.map(&:to_i).map do |sprint_id|
|
||||||
# count_closed 工作项已完成/已关闭数量,需排除已修复的缺陷数量
|
# count_closed 工作项已完成/已关闭数量,需排除已修复的缺陷数量
|
||||||
count_closed = @issues_type_count[[sprint_id, 5]].to_i + @issues_type_count[[sprint_id, 3]].to_i - @issues.where(pm_sprint_id: sprint_id, pm_issue_type: 3, status_id: 3).size
|
count_closed = @issues_type_count[[sprint_id, 5]].to_i + @issues_type_count[[sprint_id, 3]].to_i - @issues.where(pm_sprint_id: sprint_id, pm_issue_type: 3, status_id: 3).size
|
||||||
# hour_closed 已完成/已关闭 预估工时之和,需排除已修复的缺陷预估工时
|
# hour_closed 已完成/已关闭 预估工时之和,需排除已修复的缺陷预估工时
|
||||||
hour_closed = @issues_hour_type_count[[sprint_id, 5]].to_f + @issues_hour_type_count[[sprint_id, 3]].to_f - @issues.where(pm_sprint_id: sprint_id, pm_issue_type: 3, status_id: 3).sum(:time_scale).to_f
|
hour_closed = @issues_hour_type_count[[sprint_id, 5]].to_f + @issues_hour_type_count[[sprint_id, 3]].to_f - @issues.where(pm_sprint_id: sprint_id, pm_issue_type: 3, status_id: 3).sum(:time_scale).to_f
|
||||||
data[sprint_id] = {
|
data[sprint_id] = {
|
||||||
count_total: @issues_count[sprint_id] || 0,
|
count_total: @issues_count[sprint_id] || 0,
|
||||||
count_closed: count_closed || 0,
|
count_closed: count_closed || 0,
|
||||||
|
@ -56,8 +55,10 @@ class Api::Pm::SprintIssuesController < Api::Pm::BaseController
|
||||||
bug: @issues_pm_type_count[[sprint_id, 3]] || 0,
|
bug: @issues_pm_type_count[[sprint_id, 3]] || 0,
|
||||||
requirement_hour: @issues_hour_pm_type_count[[sprint_id, 1]] || 0,
|
requirement_hour: @issues_hour_pm_type_count[[sprint_id, 1]] || 0,
|
||||||
task_hour: @issues_hour_pm_type_count[[sprint_id, 2]] || 0,
|
task_hour: @issues_hour_pm_type_count[[sprint_id, 2]] || 0,
|
||||||
bug_hour: @issues_hour_pm_type_count[[sprint_id, 3]] || 0
|
bug_hour: @issues_hour_pm_type_count[[sprint_id, 3]] || 0,
|
||||||
|
requirement_open: (@issues_status_pm_type_count[[sprint_id, 1, 1]] + @issues_status_pm_type_count[[sprint_id, 1, 2]]) || 0,
|
||||||
|
task_open: @issues_status_pm_type_count[[sprint_id, 2, 1]] + @issues_status_pm_type_count[[sprint_id, 2, 2]] || 0,
|
||||||
|
bug_open: @issues_status_pm_type_count[[sprint_id, 3, 1]] + @issues_status_pm_type_count[[sprint_id, 3, 2]] || 0
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
render_ok(data: data)
|
render_ok(data: data)
|
||||||
|
@ -65,10 +66,10 @@ class Api::Pm::SprintIssuesController < Api::Pm::BaseController
|
||||||
|
|
||||||
before_action :load_uncomplete_issues, only: [:complete]
|
before_action :load_uncomplete_issues, only: [:complete]
|
||||||
|
|
||||||
def complete
|
def complete
|
||||||
begin
|
begin
|
||||||
case complete_params[:complete_type].to_i
|
case complete_params[:complete_type].to_i
|
||||||
when 1
|
when 1
|
||||||
@issues.update_all(status_id: 5)
|
@issues.update_all(status_id: 5)
|
||||||
when 2
|
when 2
|
||||||
@issues.update_all(pm_sprint_id: 0)
|
@issues.update_all(pm_sprint_id: 0)
|
||||||
|
@ -87,16 +88,16 @@ class Api::Pm::SprintIssuesController < Api::Pm::BaseController
|
||||||
@issues = Issue.where(pm_sprint_id: complete_params[:pm_project_sprint_id]).where.not(status_id: 5)
|
@issues = Issue.where(pm_sprint_id: complete_params[:pm_project_sprint_id]).where.not(status_id: 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
def complete_params
|
def complete_params
|
||||||
params.permit(:pm_project_sprint_id, :complete_type, :target_pm_project_sprint_id)
|
params.permit(:pm_project_sprint_id, :complete_type, :target_pm_project_sprint_id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def query_params
|
def query_params
|
||||||
params.permit(
|
params.permit(
|
||||||
:category,
|
:category,
|
||||||
:pm_project_id,
|
:pm_project_id,
|
||||||
:pm_issue_type, #需求1 任务2 缺陷3
|
:pm_issue_type, # 需求1 任务2 缺陷3
|
||||||
:assigner_id,
|
:assigner_id,
|
||||||
:priority_id,
|
:priority_id,
|
||||||
:status_id,
|
:status_id,
|
||||||
:keyword, :status_ids, :pm_issue_types,
|
:keyword, :status_ids, :pm_issue_types,
|
||||||
|
|
Loading…
Reference in New Issue