优化查看commits那个页面

hjq_course
Gan Yi.ang 10 years ago
parent ea47a8085a
commit f6bfd7824d

@ -354,17 +354,16 @@ update
def get_commits(id) def get_commits(id)
g = Gitlab.client g = Gitlab.client
tmp_commit = g.commits(id,page:0) tmp_commit_count = g.commits(id,page:0).count
commits = [] commit_count = 0
i=0 i=0
while tmp_commit!=[] while tmp_commit_count!=0
commits = commits+tmp_commit commit_count = commit_count+tmp_commit_count
i=i+1 i=i+1
tmp_commit = g.commits(id,page:i) tmp_commit_count = g.commits(id,page:i).count
end end
commits_count = commits.length
return commits_count return commit_count
end end
@ -377,7 +376,7 @@ update
@commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s)
@commits_count = get_commits(@project.gpid) @commits_count = params[:commit_count].to_i
@commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page]
@commit = g.commit(@project.gpid,@rev) @commit = g.commit(@project.gpid,@rev)

@ -40,7 +40,8 @@
</span> </span>
<span class="fr mr5"><font class="fb ml2 mr2 vl_commit"> <span class="fr mr5"><font class="fb ml2 mr2 vl_commit">
<%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1} %></font> 提交 <%=link_to @changesets_all_count, {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %></font> 提交
</span> </span>
</div> </div>
<% end %> <% end %>

Loading…
Cancel
Save