From 6d3d2b3adb985cf716eedd2e8b495f548b937624 Mon Sep 17 00:00:00 2001 From: Go MAEDA Date: Thu, 1 Jul 2021 01:42:42 +0000 Subject: [PATCH] Reduce amount of work on projects show API (#35374). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Patch by Felix Schäfer. git-svn-id: http://svn.redmine.org/redmine/trunk@21056 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 673c77316..9d7d37bb1 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -172,26 +172,26 @@ class ProjectsController < ApplicationController return end - @principals_by_role = @project.principals_by_role - @subprojects = @project.children.visible.to_a - @news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").to_a - with_subprojects = Setting.display_subprojects_issues? - @trackers = @project.rolled_up_trackers(with_subprojects).visible - - cond = @project.project_condition(with_subprojects) - - @open_issues_by_tracker = Issue.visible.open.where(cond).group(:tracker).count - @total_issues_by_tracker = Issue.visible.where(cond).group(:tracker).count - - if User.current.allowed_to_view_all_time_entries?(@project) - @total_hours = TimeEntry.visible.where(cond).sum(:hours).to_f - @total_estimated_hours = Issue.visible.where(cond).sum(:estimated_hours).to_f - end - - @key = User.current.rss_key - respond_to do |format| - format.html + format.html do + @principals_by_role = @project.principals_by_role + @subprojects = @project.children.visible.to_a + @news = @project.news.limit(5).includes(:author, :project).reorder("#{News.table_name}.created_on DESC").to_a + with_subprojects = Setting.display_subprojects_issues? + @trackers = @project.rolled_up_trackers(with_subprojects).visible + + cond = @project.project_condition(with_subprojects) + + @open_issues_by_tracker = Issue.visible.open.where(cond).group(:tracker).count + @total_issues_by_tracker = Issue.visible.where(cond).group(:tracker).count + + if User.current.allowed_to_view_all_time_entries?(@project) + @total_hours = TimeEntry.visible.where(cond).sum(:hours).to_f + @total_estimated_hours = Issue.visible.where(cond).sum(:estimated_hours).to_f + end + + @key = User.current.rss_key + end format.api end end