添加统计数目

This commit is contained in:
huang 2016-08-03 16:02:42 +08:00
parent b8cccdffda
commit 22a8adb64e
3 changed files with 10 additions and 6 deletions

View File

@ -51,6 +51,9 @@ class PullRequestsController < ApplicationController
@type = params[:type]
@request = @g.merge_request(@project.gpid, params[:id])
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
@commits_count = @commits.count
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count
end
# Accept a merge request.
@ -79,7 +82,8 @@ class PullRequestsController < ApplicationController
# 获取某次请求的改动
def pull_request_changes
@changes = @g.merge_request_changes(@project.gpid, params[:id])
@changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes)
@changes_count = @changes.count
end
private

View File

@ -1,7 +1,7 @@
<% if @changes %>
<% @changes.try(:changes).each do |cd| %>
<% unless @changes.blank? %>
<% @changes.each do |cd| %>
<div class="showing-changes-row fontGrey2">
<a href="javascript:void()" class="linkGrey3" id="changed-files">
<a class="linkGrey3" id="changed-files">
<img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" /><%= cd['new_path'] %>
</a>
</div>

View File

@ -12,8 +12,8 @@
</div>
</div>
<ul class="merge-record" style="border-top:1px solid #ddd;">
<li><%= link_to "提交<span class='project-number-dot'>1</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
<li><%= link_to "改动<span class='project-number-dot'>1</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
<li><%= link_to "提交<span class='project-number-dot'>#{@commits_count}</span>".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %></li>
<li><%= link_to "改动<span class='project-number-dot'>#{@changes_count}</span>".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %></li>
</ul>
<div class="new-merge-row b_grey fontGrey2"><span class="ml10"> 根据最近提交时间排列</span></div>
<div id="merge_record_0">