diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/ci/runner.rb | 6 | ||||
-rw-r--r-- | app/models/ci/runner_group.rb | 8 | ||||
-rw-r--r-- | app/models/ci/runner_namespace.rb | 9 | ||||
-rw-r--r-- | app/models/group.rb | 2 | ||||
-rw-r--r-- | app/models/namespace.rb | 3 |
5 files changed, 15 insertions, 13 deletions
diff --git a/app/models/ci/runner.rb b/app/models/ci/runner.rb index 4d4aff4c830..0b47b71a267 100644 --- a/app/models/ci/runner.rb +++ b/app/models/ci/runner.rb @@ -14,8 +14,8 @@ module Ci has_many :builds has_many :runner_projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :projects, through: :runner_projects - has_many :runner_groups - has_many :groups, through: :runner_groups + has_many :runner_namespaces + has_many :groups, through: :runner_namespaces has_one :last_build, ->() { order('id DESC') }, class_name: 'Ci::Build' @@ -144,7 +144,7 @@ module Ci end def assigned_to_group? - runner_groups.any? + runner_namespaces.any? end def assigned_to_project? diff --git a/app/models/ci/runner_group.rb b/app/models/ci/runner_group.rb deleted file mode 100644 index 87f3ba13bff..00000000000 --- a/app/models/ci/runner_group.rb +++ /dev/null @@ -1,8 +0,0 @@ -module Ci - class RunnerGroup < ActiveRecord::Base - extend Gitlab::Ci::Model - - belongs_to :runner - belongs_to :group, class_name: '::Group' - end -end diff --git a/app/models/ci/runner_namespace.rb b/app/models/ci/runner_namespace.rb new file mode 100644 index 00000000000..3269f86e8ca --- /dev/null +++ b/app/models/ci/runner_namespace.rb @@ -0,0 +1,9 @@ +module Ci + class RunnerNamespace < ActiveRecord::Base + extend Gitlab::Ci::Model + + belongs_to :runner + belongs_to :namespace, class_name: '::Namespace' + belongs_to :group, class_name: '::Group', foreign_key: :namespace_id + end +end diff --git a/app/models/group.rb b/app/models/group.rb index f21008e5f75..f493836a92e 100644 --- a/app/models/group.rb +++ b/app/models/group.rb @@ -29,8 +29,6 @@ class Group < Namespace has_many :labels, class_name: 'GroupLabel' has_many :variables, class_name: 'Ci::GroupVariable' has_many :custom_attributes, class_name: 'GroupCustomAttribute' - has_many :runner_groups, class_name: 'Ci::RunnerGroup' - has_many :runners, through: :runner_groups, source: :runner, class_name: 'Ci::Runner' has_many :uploads, as: :model, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent diff --git a/app/models/namespace.rb b/app/models/namespace.rb index c29a53e5ce7..5621eeba7c4 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -21,6 +21,9 @@ class Namespace < ActiveRecord::Base has_many :projects, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent has_many :project_statistics + has_many :runner_namespaces, class_name: 'Ci::RunnerNamespace' + has_many :runners, through: :runner_namespaces, source: :runner, class_name: 'Ci::Runner' + # This should _not_ be `inverse_of: :namespace`, because that would also set # `user.namespace` when this user creates a group with themselves as `owner`. belongs_to :owner, class_name: "User" |