Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Optimize queries for projects with many deployments. #38

Open
wants to merge 2 commits into from

2 participants

@ngan

It gets super slow when you've had a lot of deployments and many hosts. These changes optimizes the queries for role and deployment look ups.

@zedtux

Tested and approuved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 app/models/role.rb
View
6 app/models/role.rb
@@ -78,17 +78,17 @@ def unset_no_symlink!
# tells if this role had a successful setup
def setup_done?
- deployed_at_least_once? && self.deployments.any?{|x| Deployment::SETUP_TASKS.include?(x.task) && x.success? }
+ deployed_at_least_once? && self.deployments.exists?(:conditions => {"deployments.task" => Deployment::SETUP_TASKS, "deployments.status" => Deployment::STATUS_SUCCESS})
end
# tells if this role had a successful deployment (deploy)
def deployed?
- deployed_at_least_once? && self.deployments.any?{|x| Deployment::DEPLOY_TASKS.include?(x.task) && x.success? }
+ deployed_at_least_once? && self.deployments.exists?(:conditions => {"deployments.task" => Deployment::DEPLOY_TASKS, "deployments.status" => Deployment::STATUS_SUCCESS})
end
# tells if this role had any deployment at all
def deployed_at_least_once?
- !self.deployments.empty?
+ self.deployments.exists?
end
def status
Something went wrong with that request. Please try again.