Skip to content

Commit

Permalink
Remove extra queries on apps collection
Browse files Browse the repository at this point in the history
Using the scope on apps controller will yield lots of queries, so we need to call .to_a
  • Loading branch information
arthurnn committed Nov 1, 2013
1 parent 39c486a commit b0799e0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 1 addition & 2 deletions app/controllers/apps_controller.rb
Expand Up @@ -12,7 +12,7 @@ class AppsController < ApplicationController
}

expose(:apps) {
app_scope.all.sort
app_scope.all.sort.to_a
}

expose(:app, :ancestor => :app_scope)
Expand Down Expand Up @@ -143,4 +143,3 @@ def parse_notice_at_notices_or_set_default
end
end
end

11 changes: 5 additions & 6 deletions app/helpers/apps_helper.rb
Expand Up @@ -12,27 +12,27 @@ def link_to_copy_attributes_from_other_app
end

def any_github_repos?
detect_any_apps_with_attributes unless @any_github_repos
detect_any_apps_with_attributes if @any_github_repos.nil?
@any_github_repos
end

def any_notification_services?
detect_any_apps_with_attributes unless @any_notification_services
detect_any_apps_with_attributes if @any_notification_services.present?
@any_notification_services
end

def any_bitbucket_repos?
detect_any_apps_with_attributes unless @any_bitbucket_repos
detect_any_apps_with_attributes if @any_bitbucket_repos.nil?
@any_bitbucket_repos
end

def any_issue_trackers?
detect_any_apps_with_attributes unless @any_issue_trackers
detect_any_apps_with_attributes if @any_issue_trackers.nil?
@any_issue_trackers
end

def any_deploys?
detect_any_apps_with_attributes unless @any_deploys
detect_any_apps_with_attributes if @any_deploys.nil?
@any_deploys
end

Expand All @@ -50,4 +50,3 @@ def detect_any_apps_with_attributes
end
end
end

0 comments on commit b0799e0

Please sign in to comment.