项目版本库隐藏代码统计

This commit is contained in:
huang 2016-09-18 15:55:22 +08:00
parent a3467a5697
commit 924db06cbf
2 changed files with 21 additions and 32 deletions

View File

@ -325,27 +325,27 @@ class ProjectsController < ApplicationController
end
# 版本库统计图
unless @project.gpid.nil? || @project.project_score.changeset_num == 0
# rep_statics_commit = @project.rep_statics.order("commits_num desc")
rep_statics_commit = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by commits_num desc limit 10")
rep_statics_code = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by changeset desc limit 10")
# rep_statics_code = @project.rep_statics.sort_by {|u| u.changeset}.reverse
@a_uname = rep_statics_commit.map {|s| s.uname }
@a_uname_code = rep_statics_code.map {|s| s.uname }
@a_commits_num = rep_statics_commit.map {|s| s.commits_num.to_i }
@a_commits_add = rep_statics_code.map {|s| s.add.to_i }
@a_commits_del = rep_statics_code.map {|s| s.del.to_i }
@a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i }
g = Gitlab.client
begin
gid = @project.gpid
g_project = g.project(gid)
g_branch = g_project.default_branch.to_s
rescue =>e
logger.error("get default branch failed: " + e)
end
@rev = g_branch.nil? ? "master" : g_branch
end
# unless @project.gpid.nil? || @project.project_score.changeset_num == 0
# # rep_statics_commit = @project.rep_statics.order("commits_num desc")
# rep_statics_commit = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by commits_num desc limit 10")
# rep_statics_code = RepStatics.find_by_sql("SELECT * FROM `rep_statics` where project_id = #{@project.id} order by changeset desc limit 10")
# # rep_statics_code = @project.rep_statics.sort_by {|u| u.changeset}.reverse
# @a_uname = rep_statics_commit.map {|s| s.uname }
# @a_uname_code = rep_statics_code.map {|s| s.uname }
# @a_commits_num = rep_statics_commit.map {|s| s.commits_num.to_i }
# @a_commits_add = rep_statics_code.map {|s| s.add.to_i }
# @a_commits_del = rep_statics_code.map {|s| s.del.to_i }
# @a_commits_changeset = rep_statics_code.map {|s| s.changeset.to_i }
# g = Gitlab.client
# begin
# gid = @project.gpid
# g_project = g.project(gid)
# g_branch = g_project.default_branch.to_s
# rescue =>e
# logger.error("get default branch failed: " + e)
# end
# @rev = g_branch.nil? ? "master" : g_branch
# end
# 根据对应的请求,返回对应的数据
respond_to do |format|
format.html

View File

@ -29,17 +29,6 @@
<!--CONTENT LIST-->
</div>
<%# 时间紧,权限待优化 %>
<% unless @project.hidden_repo && !User.current.member_of?(@project) && !User.current.admin? %>
<% unless @project.gpid.nil? || @project.project_score.changeset_num == 0 || @project.rep_statics.blank? %>
<div class="resources mt10">
<div class="homepagePostBrief">
<%= render :partial => "rep_static" %>
<div class="cl"></div>
</div>
</div>
<% end %>
<% end %>
<%= render :partial => "project_activities", :locals => {:forge_acts => @events_pages, :page => 0, :type => @type} %>
</div>