diff options
author | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-01-25 17:50:09 +0000 |
---|---|---|
committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2017-01-25 17:50:09 +0000 |
commit | 6cfe60df2275dace9804f4bc37b9746a9eadc6fd (patch) | |
tree | 05e401f44722603121eb196d3097879b98e0aa0c /app/models | |
parent | b55c1bc4b5fb8d259ba9f264eff607f81012fa39 (diff) | |
parent | b368447cf7fbd090704e22311dde72cd293d9779 (diff) | |
download | gitlab-ce-6cfe60df2275dace9804f4bc37b9746a9eadc6fd.tar.gz |
Merge branch 'backport-ee-changes-for-build-minutes' into 'master'
Backport changes introduced by https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1078
See merge request !8657
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/namespace.rb | 5 | ||||
-rw-r--r-- | app/models/project.rb | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb index 05f01445e67..67d8c1c2e4c 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -4,6 +4,7 @@ class Namespace < ActiveRecord::Base include CacheMarkdownField include Sortable include Gitlab::ShellAdapter + include Gitlab::CurrentSettings include Routable cache_markdown_field :description, pipeline: :description @@ -176,6 +177,10 @@ class Namespace < ActiveRecord::Base end end + def shared_runners_enabled? + projects.with_shared_runners.any? + end + def full_name @full_name ||= if parent diff --git a/app/models/project.rb b/app/models/project.rb index cd35601d76b..59faf35e051 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -224,6 +224,7 @@ class Project < ActiveRecord::Base scope :with_project_feature, -> { joins('LEFT JOIN project_features ON projects.id = project_features.project_id') } scope :with_statistics, -> { includes(:statistics) } + scope :with_shared_runners, -> { where(shared_runners_enabled: true) } # "enabled" here means "not disabled". It includes private features! scope :with_feature_enabled, ->(feature) { @@ -1096,12 +1097,20 @@ class Project < ActiveRecord::Base project_feature.update_attribute(:builds_access_level, ProjectFeature::ENABLED) end + def shared_runners_available? + shared_runners_enabled? + end + + def shared_runners + shared_runners_available? ? Ci::Runner.shared : Ci::Runner.none + end + def any_runners?(&block) if runners.active.any?(&block) return true end - shared_runners_enabled? && Ci::Runner.shared.active.any?(&block) + shared_runners.active.any?(&block) end def valid_runners_token?(token) |