From 792222a36ae8ce5ac715c09419b9e179cf9d6e44 Mon Sep 17 00:00:00 2001 From: "sylor_huang@126.com" Date: Fri, 28 Feb 2020 13:34:53 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8A=A8=E6=80=81=E7=9A=84?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/project_trends_controller.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/controllers/project_trends_controller.rb b/app/controllers/project_trends_controller.rb index 15a22bf39..1a3d8d3ff 100644 --- a/app/controllers/project_trends_controller.rb +++ b/app/controllers/project_trends_controller.rb @@ -4,11 +4,6 @@ class ProjectTrendsController < ApplicationController def index project_trends = @project.project_trends.includes(:user, trend: :user) - @project_open_issues_count = project_trends.where(trend_type: "Issue", action_type: "create").size - @project_close_issues_count = project_trends.where(trend_type: "Issue", action_type: "close").size - @project_issues_count = @project_open_issues_count + @project_close_issues_count - @project_pr_count = project_trends.where(trend_type: "PullRequest", action_type: "close").size - @project_new_pr_count = project_trends.where(trend_type: "PullRequest", action_type: "create").size check_time = params[:time] #时间的筛选 check_type = params[:type] #动态类型的筛选,目前已知的有 Issue, PullRequest, Version @@ -19,6 +14,12 @@ class ProjectTrendsController < ApplicationController project_trends = project_trends.where("created_at between ? and ?",(Time.now.beginning_of_day - check_time.days), Time.now.end_of_day) end + @project_open_issues_count = project_trends.where(trend_type: "Issue", action_type: "create").size + @project_close_issues_count = project_trends.where(trend_type: "Issue", action_type: "close").size + @project_issues_count = @project_open_issues_count + @project_close_issues_count + @project_pr_count = project_trends.where(trend_type: "PullRequest", action_type: "close").size + @project_new_pr_count = project_trends.where(trend_type: "PullRequest", action_type: "create").size + if check_type.present? project_trends = project_trends.where(trend_type: check_type.to_s.strip) end