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? %> +
贡献统计
+
+ + + <% @user_quality_infos.each do |author_info| %> + <% user = get_user_by_mail(author_info[:email]) %> + + <% end %> + +
+<% end %> + diff --git a/lib/gitlab-cli/lib/gitlab/client/repositories.rb b/lib/gitlab-cli/lib/gitlab/client/repositories.rb index e998ab56b..80d1058b5 100644 --- a/lib/gitlab-cli/lib/gitlab/client/repositories.rb +++ b/lib/gitlab-cli/lib/gitlab/client/repositories.rb @@ -117,6 +117,11 @@ class Gitlab::Client end alias_method :repo_rep_stats, :rep_stats + def rep_user_stats(project, options={}) + get("/projects/#{project}/repository/rep_user_stats", :query => options) + end + alias_method :repo_rep_stats, :rep_stats + # Gets a tree activities of project repository. # # @example