diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-01-25 10:47:58 +0100 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-01-25 10:47:58 +0100 |
commit | b368447cf7fbd090704e22311dde72cd293d9779 (patch) | |
tree | 4e34665813874679da769d402690425baec178d6 | |
parent | ac92554dfc25fc8129b1972da9a385af8d8b733f (diff) | |
download | gitlab-ce-b368447cf7fbd090704e22311dde72cd293d9779.tar.gz |
Remove unneeded code and fix offensesbackport-ee-changes-for-build-minutes
-rw-r--r-- | app/models/project.rb | 11 | ||||
-rw-r--r-- | lib/ci/api/builds.rb | 2 | ||||
-rw-r--r-- | lib/prependable.rb | 24 | ||||
-rw-r--r-- | spec/lib/prependable_spec.rb | 47 |
4 files changed, 11 insertions, 73 deletions
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) diff --git a/lib/ci/api/builds.rb b/lib/ci/api/builds.rb index 6c869cde515..a9da8ea7eeb 100644 --- a/lib/ci/api/builds.rb +++ b/lib/ci/api/builds.rb @@ -24,7 +24,7 @@ module Ci new_update = current_runner.ensure_runner_queue_value build = Ci::RegisterBuildService.new(current_runner).execute -
+ if build Gitlab::Metrics.add_event(:build_found, project: build.project.path_with_namespace) diff --git a/lib/prependable.rb b/lib/prependable.rb deleted file mode 100644 index ff0630d9da3..00000000000 --- a/lib/prependable.rb +++ /dev/null @@ -1,24 +0,0 @@ -# This module is based on: https://gist.github.com/bcardarella/5735987 - -module Prependable - include ActiveSupport::Concern - - def self.extended(base) #:nodoc: - base.instance_variable_set(:@_dependencies, []) - end - - def prepend_features(base) - if base.instance_variable_defined?(:@_dependencies) - base.instance_variable_get(:@_dependencies) << self - return false - else - return false if base < self - super - base.singleton_class.send(:prepend, const_get('ClassMethods')) if const_defined?(:ClassMethods) - @_dependencies.each { |dep| base.send(:include, dep) } - base.class_eval(&@_included_block) if instance_variable_defined?(:@_included_block) - end - end - - alias_method :prepended, :included -end diff --git a/spec/lib/prependable_spec.rb b/spec/lib/prependable_spec.rb deleted file mode 100644 index 7a338624e9e..00000000000 --- a/spec/lib/prependable_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -require 'spec_helper' - -describe Prependable do - subject { FooObject } - - context 'class methods' do - it "has a method" do - expect(subject).to respond_to(:class_value) - end - - it 'can execute a method' do - expect(subject.class_value).to eq(20) - end - end - - context 'instance methods' do - it "has a method" do - expect(subject.new).to respond_to(:value) - end - - it 'chains a method execution' do - expect(subject.new.value).to eq(100) - end - end - - module Foo - extend Prependable - - prepended do - def self.class_value - 20 - end - end - - def value - super * 10 - end - end - - class FooObject - prepend Foo - - def value - 10 - end - end -end |