diff options
author | Douwe Maan <douwe@gitlab.com> | 2017-04-06 21:46:02 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2017-04-06 21:46:02 +0000 |
commit | 5fbb9e95449fd521447aa802269962c5a972467f (patch) | |
tree | 8e88ece4f8f516753bc6474ea5ca17cd5cffbb68 /app/models/project.rb | |
parent | 197dad2eedc3722124b570e650432cf58650d07e (diff) | |
parent | 37a7b099d6eafc87209368a9fc7f608282b99e08 (diff) | |
download | gitlab-ce-5fbb9e95449fd521447aa802269962c5a972467f.tar.gz |
Merge branch 'optimise-pipelines' into 'master'
Optimise pipelines.json
See merge request !10462
Diffstat (limited to 'app/models/project.rb')
-rw-r--r-- | app/models/project.rb | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 19835a72a75..2b467f95087 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -172,6 +172,8 @@ class Project < ActiveRecord::Base has_many :environments, dependent: :destroy has_many :deployments, dependent: :destroy + has_many :active_runners, -> { active }, through: :runner_projects, source: :runner, class_name: 'Ci::Runner' + accepts_nested_attributes_for :variables, allow_destroy: true accepts_nested_attributes_for :project_feature @@ -1085,15 +1087,15 @@ class Project < ActiveRecord::Base end def shared_runners - shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none + @shared_runners ||= shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none end - def any_runners?(&block) - if runners.active.any?(&block) - return true - end + def active_shared_runners + @active_shared_runners ||= shared_runners.active + end - shared_runners.active.any?(&block) + def any_runners?(&block) + active_runners.any?(&block) || active_shared_runners.any?(&block) end def valid_runners_token?(token) |