Commit 921f2248 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Make limit to not be enabled if project is public

parent bf5198ac
......@@ -29,7 +29,7 @@ class Project < ActiveRecord::Base
allow_nil: true
delegate :shared_runners_minutes, :shared_runners_minutes_limit,
:shared_runners_minutes_used?, :shared_runners_minutes_limit_enabled?,
:shared_runners_minutes_used?,
to: :namespace, allow_nil: true
default_value_for :archived, false
......@@ -1547,6 +1547,10 @@ class Project < ActiveRecord::Base
end
end
def shared_runners_minutes_limit_enabled?
!public? && namespace.shared_runners_minutes_limit_enabled?
end
private
# Check if a reference is being done cross-project
......
......@@ -4,12 +4,9 @@ class UpdateBuildMinutesService < BaseService
return unless build.runner.shared?
return unless build.duration
return unless build.project
return if build.project.public?
return unless build.project.shared_runners_minutes_limit_enabled?
namespace = project.namespace
return unless namespace
namespace.find_or_create_project_metrics.
project.namespace.find_or_create_namespace_metrics.
update_all('shared_runners_minutes = shared_runners_minutes + ?', build.duration)
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment