Commit b0799e040addd2e341389c0bb4e34dd023b114b8

Authored by Arthur Neves
1 parent 39c486a8
Exists in master and in 1 other branch production

Remove extra queries on apps collection

Using the scope on apps controller will yield lots of queries, so we need to call .to_a
app/controllers/apps_controller.rb
... ... @@ -12,7 +12,7 @@ class AppsController < ApplicationController
12 12 }
13 13  
14 14 expose(:apps) {
15   - app_scope.all.sort
  15 + app_scope.all.sort.to_a
16 16 }
17 17  
18 18 expose(:app, :ancestor => :app_scope)
... ... @@ -143,4 +143,3 @@ class AppsController < ApplicationController
143 143 end
144 144 end
145 145 end
146   -
... ...
app/helpers/apps_helper.rb
... ... @@ -12,27 +12,27 @@ module AppsHelper
12 12 end
13 13  
14 14 def any_github_repos?
15   - detect_any_apps_with_attributes unless @any_github_repos
  15 + detect_any_apps_with_attributes if @any_github_repos.nil?
16 16 @any_github_repos
17 17 end
18 18  
19 19 def any_notification_services?
20   - detect_any_apps_with_attributes unless @any_notification_services
  20 + detect_any_apps_with_attributes if @any_notification_services.present?
21 21 @any_notification_services
22 22 end
23 23  
24 24 def any_bitbucket_repos?
25   - detect_any_apps_with_attributes unless @any_bitbucket_repos
  25 + detect_any_apps_with_attributes if @any_bitbucket_repos.nil?
26 26 @any_bitbucket_repos
27 27 end
28 28  
29 29 def any_issue_trackers?
30   - detect_any_apps_with_attributes unless @any_issue_trackers
  30 + detect_any_apps_with_attributes if @any_issue_trackers.nil?
31 31 @any_issue_trackers
32 32 end
33 33  
34 34 def any_deploys?
35   - detect_any_apps_with_attributes unless @any_deploys
  35 + detect_any_apps_with_attributes if @any_deploys.nil?
36 36 @any_deploys
37 37 end
38 38  
... ... @@ -50,4 +50,3 @@ module AppsHelper
50 50 end
51 51 end
52 52 end
53   -
... ...