branch's total commits

dev_shcool
txz 9 years ago
parent 21be94cbe1
commit 7178c50b1d

@ -360,11 +360,6 @@ update
end end
def show def show
# sonar_address = Redmine::Configuration['sonar_address']
# projects_date = open(sonar_address + "/api/projects/index").read
# arr = JSON.parse(projects_date).map {|m| m["nm"]}
# arr.map
## TODO: the below will move to filter, done. ## TODO: the below will move to filter, done.
if !User.current.member_of?(@project) && @project.hidden_repo if !User.current.member_of?(@project) && @project.hidden_repo
render_403 render_403
@ -379,7 +374,7 @@ update
@changesets = g.commits(@project.gpid, :ref_name => @rev) @changesets = g.commits(@project.gpid, :ref_name => @rev)
g_project = g.project(@project.gpid) g_project = g.project(@project.gpid)
# 总的提交数 # 总的提交数
@changesets_all_count = @project.gpid.nil? ? 0 : g_project.commit_count @changesets_all_count = @project.gpid.nil? ? 0 : commit_count(@project, @rev)
@g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch @g_default_branch = g_project.default_branch.nil? ? "master" : g_project.default_branch
# 访问该页面的是会后则刷新 # 访问该页面的是会后则刷新
if @project.project_score.nil? if @project.project_score.nil?

@ -803,22 +803,22 @@ module ApplicationHelper
end end
# 获取Gitlab版本库提交总数 # 获取Gitlab版本库提交总数
def commit_count(project) def commit_count(project, branch)
g = Gitlab.client g = Gitlab.client
#add by hx #add by hx
if g.commits(project.gpid , :page=>200).count > 0 if g.commits(project.gpid, :ref_name => @rev , :page=>200).count > 0
count = 4020 count = 4020
elsif g.commits(project.gpid , :page=>25).count==0 elsif g.commits(project.gpid , :page=>25, :ref_name => branch).count==0
count = count_commits(project.gpid , 0 , 25) count = count_commits(project.gpid , 0 , 25)
elsif g.commits(project.gpid , :page=>50).count ==0 elsif g.commits(project.gpid , :page=>50, :ref_name => branch).count ==0
count = count_commits(project.gpid , 25 , 50)+ 25 * 20 count = count_commits(project.gpid , 25 , 50)+ 25 * 20
elsif g.commits(project.gpid , :page=>75).count ==0 elsif g.commits(project.gpid , :page=>75, :ref_name => branch).count ==0
count = count_commits(project.gpid , 50 , 75)+ 50 * 20 count = count_commits(project.gpid , 50 , 75)+ 50 * 20
elsif g.commits(project.gpid , :page=>100).count== 0 elsif g.commits(project.gpid , :page=>100, :ref_name => branch).count== 0
count = count_commits(project.gpid , 75 , 100) + 75 * 20 count = count_commits(project.gpid , 75 , 100) + 75 * 20
elsif g.commits(project.gpid , :page=>125).count==0 elsif g.commits(project.gpid , :page=>125, :ref_name => branch).count==0
count = count_commits(project.gpid , 100 , 125) + 100 * 20 count = count_commits(project.gpid , 100 , 125) + 100 * 20
elsif g.commits(project.gpid , :page=>150).count==0 elsif g.commits(project.gpid , :page=>150, :ref_name => branch).count==0
count = count_commits(project.gpid , 125 , 150) + 125 * 20 count = count_commits(project.gpid , 125 , 150) + 125 * 20
else else
count = count_commits(project.gpid , 150 ,200) + 150 * 20 count = count_commits(project.gpid , 150 ,200) + 150 * 20
@ -832,7 +832,7 @@ module ApplicationHelper
if $g.commits(project_id,:page => page).count == 0 if $g.commits(project_id,:page => page).count == 0
break break
else else
count = count + $g.commits(project_id,:page => page).count count = count + $g.commits(project_id, :ref_name => @rev, :page => page).count
end end
end end
return count return count

Loading…
Cancel
Save