贡献列表
This commit is contained in:
parent
0cc59260cd
commit
60a76e64a5
|
@ -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|
|
||||
|
|
|
@ -127,46 +127,33 @@
|
|||
<p class="fontBlue2"><%= @ha["functions"].to_i %></p>
|
||||
</div>
|
||||
</div>
|
||||
<!--<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">贡献统计</span></div>-->
|
||||
<!--<div class="analysis-block mt10 f12">-->
|
||||
<!--<ul class="contribute-list">-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-avatar"> </li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-code">代码行数</li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-problem">引入质量问题数</li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-rate">引入质量问题数/代码行数</li>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</ul>-->
|
||||
<!--<ul class="contribute-list">-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">-->
|
||||
<!--<div class="mt8"><img src="images/homepageImage.jpg" width="50" class="image-cir" />-->
|
||||
<!--<p class="fontGrey2 hidden">小明</p>-->
|
||||
<!--</div>-->
|
||||
<!--</li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height">18340</li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height">230</li>-->
|
||||
<!--<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height">.012540</li>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</ul>-->
|
||||
<!--<ul class="contribute-list">-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">-->
|
||||
<!--<div class="mt8"><img src="images/homepageImage.jpg" width="50" class="image-cir" />-->
|
||||
<!--<p class="fontGrey2 hidden">小王</p>-->
|
||||
<!--</div>-->
|
||||
<!--</li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height">834</li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height">34</li>-->
|
||||
<!--<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height">.04077</li>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</ul>-->
|
||||
<!--<ul class="contribute-list">-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">-->
|
||||
<!--<div class="mt8"><img src="images/homepageImage.jpg" width="50" class="image-cir" />-->
|
||||
<!--<p class="fontGrey2 hidden">小亮</p>-->
|
||||
<!--</div>-->
|
||||
<!--</li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height">134</li>-->
|
||||
<!--<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height">10</li>-->
|
||||
<!--<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height">.07462</li>-->
|
||||
<!--<div class="cl"></div>-->
|
||||
<!--</ul>-->
|
||||
<!--</div>-->
|
||||
<% unless @user_quality_infos.blank? %>
|
||||
<div class="analysis-tag-wrap f16"> <span class="analysis-tag fl mr15"></span> <span class="fb fl">贡献统计</span></div>
|
||||
<div class="analysis-block mt10 f12">
|
||||
<ul class="contribute-list">
|
||||
<li class="fl fontGrey2 contribute-list-avatar"> </li>
|
||||
<li class="fl fontGrey2 contribute-list-code">代码行数</li>
|
||||
<li class="fl fontGrey2 contribute-list-problem">引入质量问题数</li>
|
||||
<li class="fl fontGrey2 contribute-list-rate">引入质量问题数/代码行数</li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
|
||||
<% @user_quality_infos.each do |author_info| %>
|
||||
<% user = get_user_by_mail(author_info[:email]) %>
|
||||
<ul class="contribute-list">
|
||||
<li class="fl fontGrey2 contribute-list-avatar contribute-list-height">
|
||||
<div class="mt8">
|
||||
<%=link_to image_tag(url_to_avatar(user), :width => "50", :height => "30"), user_path(user), :class => "image-cir", :target => '_blank' %>
|
||||
<p class="fontGrey2 hidden"><%=link_to (user.id == 2 ? author_info[:email] : user.show_name), user_path(user) %></p>
|
||||
</div>
|
||||
</li>
|
||||
<li class="fl fontGrey2 contribute-list-code contribute-list-height contribute-list-line-height"><%= author_info[:changes] %></li>
|
||||
<li class="fl fontGrey2 contribute-list-problem contribute-list-height contribute-list-line-height"><%= author_info[:issue_count] %></li>
|
||||
<li class="fl contribute-list-rate fontBlue2 contribute-list-height contribute-list-line-height"><%= author_info[:ratio] %></li>
|
||||
<div class="cl"></div>
|
||||
</ul>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue