Merge branch 'pm_project_develop' of https://gitlink.org.cn/Trustie/forgeplus into pm_project_develop
This commit is contained in:
commit
c88c64b33b
|
@ -182,7 +182,7 @@ class Api::Pm::IssuesController < Api::Pm::BaseController
|
||||||
|
|
||||||
def batch_issue_params
|
def batch_issue_params
|
||||||
params.permit(
|
params.permit(
|
||||||
:status_id, :priority_id, :milestone_id, :pm_sprint_id, :pm_issue_type, :root_id, :target_pm_project_id, :project_id,
|
:status_id, :priority_id, :milestone_id, :pm_sprint_id, :due_date, :pm_issue_type, :root_id, :target_pm_project_id, :project_id,
|
||||||
:issue_tag_ids => [],
|
:issue_tag_ids => [],
|
||||||
:assigner_ids => [] )
|
:assigner_ids => [] )
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
|
||||||
type_status = @issues.group(:pm_issue_type,:status_id).count
|
type_status = @issues.group(:pm_issue_type,:status_id).count
|
||||||
type_status_data = {}
|
type_status_data = {}
|
||||||
IssueStatus.all.map do |e|
|
IssueStatus.all.map do |e|
|
||||||
type_count_data.keys.map{ |type|
|
[1,2,3].map{ |type|
|
||||||
type_status_data[type] = {} if type_status_data[type].nil?
|
type_status_data[type] = {} if type_status_data[type].nil?
|
||||||
if type_status[[type,e.id]].nil?
|
if type_status[[type,e.id]].nil?
|
||||||
type_status_data[type][e.id] = 0
|
type_status_data[type][e.id] = 0
|
||||||
|
@ -53,9 +53,15 @@ class Api::Pm::ProjectsController < Api::Pm::BaseController
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
open_data = {
|
||||||
|
"1": type_status_data[1][1].to_i + type_status_data[1][2].to_i,
|
||||||
|
"2": type_status_data[2][1].to_i + type_status_data[2][2].to_i,
|
||||||
|
"3": type_status_data[3][1].to_i + type_status_data[3][2].to_i,
|
||||||
|
}
|
||||||
data = {
|
data = {
|
||||||
pie_chart: type_count_data,
|
pie_chart: type_count_data,
|
||||||
bar_chart: type_status_data
|
bar_chart: type_status_data,
|
||||||
|
open_data: open_data
|
||||||
}
|
}
|
||||||
render_ok(data: data)
|
render_ok(data: data)
|
||||||
end
|
end
|
||||||
|
@ -63,10 +69,9 @@ 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)
|
@create_issues = Issue.where(pm_project_id: 179,created_on: time_line)
|
||||||
@create_issues = Issue.where(pm_project_id: 135,created_on: time_line)
|
@due_issues = Issue.where(pm_project_id: params[:pm_project_id],status_id:[3,5],due_date: 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 = {
|
||||||
|
@ -75,17 +80,32 @@ 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
|
||||||
|
if @create_issues_count.present?
|
||||||
data[:create_issues][current_time] = {
|
data[:create_issues][current_time] = {
|
||||||
"1": @create_issues_count[[1,current_time]] || 0,
|
"1": @create_issues_count[[1,current_time]] || 0,
|
||||||
"2": @create_issues_count[[2,current_time]] || 0,
|
"2": @create_issues_count[[2,current_time]] || 0,
|
||||||
"3": @create_issues_count[[3,current_time]] || 0
|
"3": @create_issues_count[[3,current_time]] || 0
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
data[:create_issues][current_time] = {
|
||||||
|
"1": 0,
|
||||||
|
"2": 0,
|
||||||
|
"3": 0
|
||||||
|
}
|
||||||
|
end
|
||||||
|
if @due_issues_count.present?
|
||||||
data[:due_issues][current_time] = {
|
data[:due_issues][current_time] = {
|
||||||
"1": @due_issues_count[[1,current_time]] || 0,
|
"1": @due_issues_count[[1,current_time]] || 0,
|
||||||
"2": @due_issues_count[[2,current_time]] || 0,
|
"2": @due_issues_count[[2,current_time]] || 0,
|
||||||
"3": @due_issues_count[[3,current_time]] || 0
|
"3": @due_issues_count[[3,current_time]] || 0
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
data[:due_issues][current_time] = {
|
||||||
|
"1": 0,
|
||||||
|
"2": 0,
|
||||||
|
"3": 0
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
render_ok(data: data)
|
render_ok(data: data)
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,8 +8,6 @@ class Api::Pm::SprintIssuesController < Api::Pm::BaseController
|
||||||
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])
|
||||||
|
@ -41,6 +39,7 @@ 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).count
|
||||||
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
|
||||||
|
@ -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]].to_i + @issues_status_pm_type_count[[sprint_id, 1, 2]].to_i) || 0,
|
||||||
|
task_open: @issues_status_pm_type_count[[sprint_id, 2, 1]].to_i + @issues_status_pm_type_count[[sprint_id, 2, 2]].to_i || 0,
|
||||||
|
bug_open: @issues_status_pm_type_count[[sprint_id, 3, 1]].to_i + @issues_status_pm_type_count[[sprint_id, 3, 2]].to_i || 0
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
render_ok(data: data)
|
render_ok(data: data)
|
||||||
|
|
|
@ -104,9 +104,28 @@ class Issue < ApplicationRecord
|
||||||
scope :closed, ->{where(status_id: 5)}
|
scope :closed, ->{where(status_id: 5)}
|
||||||
scope :opened, ->{where.not(status_id: 5)}
|
scope :opened, ->{where.not(status_id: 5)}
|
||||||
after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic
|
after_create :incre_project_common, :incre_user_statistic, :incre_platform_statistic
|
||||||
|
before_save :check_pm_and_update_due_date
|
||||||
after_save :change_versions_count, :send_update_message_to_notice_system, :associate_attachment_container, :generate_uuid
|
after_save :change_versions_count, :send_update_message_to_notice_system, :associate_attachment_container, :generate_uuid
|
||||||
after_destroy :update_closed_issues_count_in_project!, :decre_project_common, :decre_user_statistic, :decre_platform_statistic
|
after_destroy :update_closed_issues_count_in_project!, :decre_project_common, :decre_user_statistic, :decre_platform_statistic
|
||||||
|
|
||||||
|
def check_pm_and_update_due_date
|
||||||
|
if pm_project_id.present? && pm_issue_type.present? && status_id_changed?
|
||||||
|
status_ids = case pm_issue_type
|
||||||
|
when 1
|
||||||
|
[3,5]
|
||||||
|
when 2
|
||||||
|
[3,5]
|
||||||
|
when 3
|
||||||
|
[5]
|
||||||
|
else
|
||||||
|
[]
|
||||||
|
end
|
||||||
|
if status_ids.include? self.status_id
|
||||||
|
self.due_date = self.due_date || Time.current
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def incre_project_common
|
def incre_project_common
|
||||||
CacheAsyncSetJob.perform_later('project_common_service', {issues: 1}, self.project_id)
|
CacheAsyncSetJob.perform_later('project_common_service', {issues: 1}, self.project_id)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue