pull request统计数显示所有

This commit is contained in:
huang 2016-10-28 15:47:05 +08:00
parent fe9731c11c
commit 3699ddd398
1 changed files with 8 additions and 6 deletions

View File

@ -17,19 +17,21 @@ class PullRequestsController < ApplicationController
@allow_to_pull_request = allow_pull_request(@project) > 0
type = params[:type]
merge_requests = @g.merge_requests(@project.gpid)
merge_requests_count = merge_requests.count
case type
when nil, "1"
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "opened" || request.state == "reopened"}
@requests = merge_requests.select{|request| request.state == "opened" || request.state == "reopened"}
# 更新统计数字
project_score = @project.project_score.update_column(:pull_request_num, @requests.count)
project_score = @project.project_score.update_column(:pull_request_num, merge_requests_count)
when "2"
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}
@requests = merge_requests.select{|request| request.state == "merged"}
when "3"
@requests = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}
@requests = merge_requests.select{|request| request.state == "closed"}
end
@requests_opened_count = @requests.count
@requests_merged_count = @g.merge_requests(@project.gpid).select{|request| request.state == "merged"}.count
@requests_closed_count = @g.merge_requests(@project.gpid).select{|request| request.state == "closed"}.count
@requests_merged_count = merge_requests.select{|request| request.state == "merged"}.count
@requests_closed_count = merge_requests.select{|request| request.state == "closed"}.count
@limit = 10
@is_remote = true