]> source.dussan.org Git - redmine.git/commitdiff
Avoid executing the same SQL statement multiple times to get the default custom query...
authorGo MAEDA <maeda@farend.jp>
Wed, 4 Aug 2021 12:48:54 +0000 (12:48 +0000)
committerGo MAEDA <maeda@farend.jp>
Wed, 4 Aug 2021 12:48:54 +0000 (12:48 +0000)
git-svn-id: http://svn.redmine.org/redmine/trunk@21134 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/helpers/queries_helper.rb

index a76ae957322f1d1eaafde68146e85f447e926755..9b223f84a7ce5210eb653fcebc85bada96dc1747 100644 (file)
@@ -465,6 +465,7 @@ module QueriesHelper
       else
         {}
       end
+    default_query_by_class = {}
     content_tag('h3', title) + "\n" +
       content_tag(
         'ul',
@@ -473,7 +474,9 @@ module QueriesHelper
           clear_link = +''
           clear_link_param = {:set_filter => 1, :sort => '', :project_id => @project}
 
-          if query == query.class.default(project: @project)
+          default_query =
+            default_query_by_class[query.class] ||= query.class.default(project: @project)
+          if query == default_query
             css << ' default'
             clear_link_param[:without_default] = 1
           end