2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-25 12:07:36 +05:30
|
|
|
module Ci
|
2021-10-27 15:23:28 +05:30
|
|
|
class RunnerProject < Ci::ApplicationRecord
|
2021-06-08 01:23:25 +05:30
|
|
|
include Limitable
|
|
|
|
|
|
|
|
self.limit_name = 'ci_registered_project_runners'
|
|
|
|
self.limit_scope = :project
|
2021-09-04 01:27:46 +05:30
|
|
|
self.limit_relation = :recent_runners
|
2015-09-25 12:07:36 +05:30
|
|
|
|
2018-11-08 19:23:39 +05:30
|
|
|
belongs_to :runner, inverse_of: :runner_projects
|
|
|
|
belongs_to :project, inverse_of: :runner_projects
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2021-09-04 01:27:46 +05:30
|
|
|
def recent_runners
|
|
|
|
::Ci::Runner.belonging_to_project(project_id).recent
|
|
|
|
end
|
|
|
|
|
2017-08-17 22:00:37 +05:30
|
|
|
validates :runner_id, uniqueness: { scope: :project_id }
|
2015-09-25 12:07:36 +05:30
|
|
|
end
|
|
|
|
end
|