From 3af96c96e7b7889c1ccf36d3fbaf492dd2c9fab8 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 23 Nov 2015 21:07:43 +0800 Subject: [PATCH] finalize the commit_counts problems by hx --- app/controllers/repositories_controller.rb | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 36deafde4..7f7b24a34 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -315,6 +315,17 @@ update #Modified by young # (show_error_not_found; return) unless @entries g = Gitlab.client + # count = 0 + # (0..100).each do |page| + # if g.commits(@project.gpid,:page => page).count == 0 + # break + # else + # count = count + g.commits(@project.gpid,:page => page).count + # end + # end + + + #add by hx if g.commits(@project.gpid , :page=>25).count==0 count = count_commits(@project.gpid , 0 , 25) elsif g.commits(@project.gpid , :page=>50).count ==0 @@ -323,8 +334,12 @@ update count = count_commits(@project.gpid , 50 , 75)+ 50 * 20 elsif g.commits(@project.gpid , :page=>100).count== 0 count = count_commits(@project.gpid , 75 , 100) + 75 * 20 - else + elsif g.commits(@project.gpid , :page=>125).count==0 count = count_commits(@project.gpid , 100 , 125) + 100 * 20 + elsif g.commits(@project.gpid , :page=>150).count==0 + count = count_commits(@project.gpid , 125 , 150) + 125 * 20 + else + count = count_commits(@project.gpid , 150 ,200) + 150 * 20 end @changesets = g.commits(@project.gpid) @@ -353,6 +368,7 @@ update alias_method :browse, :show + #add by hx def count_commits(project_id , left , right) count = 0 (left..right).each do |page|