From b7f4553e3e4681d5a4a53af35650bcbb1c83b390 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Fri, 20 Jan 2017 12:25:53 +0100 Subject: Backport changes introduced by https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/1083 --- app/models/namespace.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'app/models') diff --git a/app/models/namespace.rb b/app/models/namespace.rb index d41833de66f..778b9c127ad 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 @@ -174,6 +175,10 @@ class Namespace < ActiveRecord::Base end end + def shared_runners_enabled? + projects.with_shared_runners.any? + end + def full_name @full_name ||= if parent -- cgit v1.2.1 From b368447cf7fbd090704e22311dde72cd293d9779 Mon Sep 17 00:00:00 2001 From: Kamil Trzcinski Date: Wed, 25 Jan 2017 10:47:58 +0100 Subject: Remove unneeded code and fix offenses --- app/models/project.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'app/models') 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) -- cgit v1.2.1