]> source.dussan.org Git - redmine.git/commitdiff
Reduce amount of work on projects show API (#35374).
authorGo MAEDA <maeda@farend.jp>
Thu, 1 Jul 2021 01:42:42 +0000 (01:42 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 1 Jul 2021 01:42:42 +0000 (01:42 +0000)
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

index 673c7731685830687f387157f7b4c3264792d966..9d7d37bb159f420b26d6f7ba7b672ad0c7463083 100644 (file)
@@ -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)
+    respond_to do |format|
+      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
 
-    @open_issues_by_tracker = Issue.visible.open.where(cond).group(:tracker).count
-    @total_issues_by_tracker = Issue.visible.where(cond).group(:tracker).count
+        cond = @project.project_condition(with_subprojects)
 
-    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
+        @open_issues_by_tracker = Issue.visible.open.where(cond).group(:tracker).count
+        @total_issues_by_tracker = Issue.visible.where(cond).group(:tracker).count
 
-    @key = User.current.rss_key
+        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
 
-    respond_to do |format|
-      format.html
+        @key = User.current.rss_key
+      end
       format.api
     end
   end