2018-08-03 03:15:25 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-08-25 21:42:46 -04:00
|
|
|
module Ci
|
2021-08-03 02:08:50 -04:00
|
|
|
class RunnerProject < Ci::ApplicationRecord
|
2021-05-05 17:09:59 -04:00
|
|
|
include Limitable
|
|
|
|
|
|
|
|
self.limit_name = 'ci_registered_project_runners'
|
|
|
|
self.limit_scope = :project
|
2021-06-02 11:09:59 -04:00
|
|
|
self.limit_relation = :recent_runners
|
2021-08-04 14:09:57 -04:00
|
|
|
self.limit_feature_flag_for_override = :ci_runner_limits_override
|
2017-03-17 19:06:11 -04:00
|
|
|
|
2018-05-28 07:07:28 -04:00
|
|
|
belongs_to :runner, inverse_of: :runner_projects
|
|
|
|
belongs_to :project, inverse_of: :runner_projects
|
2015-08-25 21:42:46 -04:00
|
|
|
|
2021-06-02 11:09:59 -04:00
|
|
|
def recent_runners
|
|
|
|
::Ci::Runner.belonging_to_project(project_id).recent
|
|
|
|
end
|
|
|
|
|
2017-03-17 19:06:11 -04:00
|
|
|
validates :runner_id, uniqueness: { scope: :project_id }
|
2015-08-25 21:42:46 -04:00
|
|
|
end
|
|
|
|
end
|