diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb index a0b275dc7..f0189a9b0 100644 --- a/app/controllers/quality_analysis_controller.rb +++ b/app/controllers/quality_analysis_controller.rb @@ -241,6 +241,19 @@ class QualityAnalysisController < ApplicationController complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=#{filter}").read @complexity =JSON.parse(complexity_date).first + # 获取排名结果 + @g = Gitlab.client + author_infos = @g.rep_user_stats(@project.gpid, :rev => @branch) + @user_quality_infos = [] + author_infos.each do |author_info| + email = author_info.email + changes = author_info.changes.to_i + user_issues = open(@sonar_address + "/api/issues/search?projectKeys=#{@resource_id}&authors=#{email}&resolved=false").read + issue_count = JSON.parse(user_issues)["total"].to_i + ratio = (changes == 0 ? 0 : issue_count%changes) + @user_quality_infos << {:email => email, :changes => changes, :issue_count => issue_count, :ratio => ratio} + end + # 按名称转换成hash键值对 @ha = {} @complexity["msr"].each do |com| diff --git a/app/views/quality_analysis/_show.html.erb b/app/views/quality_analysis/_show.html.erb index f07225cc7..fc8146a02 100644 --- a/app/views/quality_analysis/_show.html.erb +++ b/app/views/quality_analysis/_show.html.erb @@ -127,46 +127,33 @@
<%= @ha["functions"].to_i %>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +<% unless @user_quality_infos.blank? %> +