Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-12-01 15:09:17 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-12-01 15:09:17 +0300
commit7b2635a55d4e87431bae752bd44c6fd2d2657b03 (patch)
tree88182aabb51a167e10f6c3a6d404b2247613047f /app/models/analytics
parenta7704bf16a51a8c993215a69db17232e3f246b8e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/analytics')
-rw-r--r--app/models/analytics/devops_adoption.rb6
-rw-r--r--app/models/analytics/devops_adoption/segment.rb24
-rw-r--r--app/models/analytics/devops_adoption/segment_selection.rb36
3 files changed, 0 insertions, 66 deletions
diff --git a/app/models/analytics/devops_adoption.rb b/app/models/analytics/devops_adoption.rb
deleted file mode 100644
index ed5a5b16a6e..00000000000
--- a/app/models/analytics/devops_adoption.rb
+++ /dev/null
@@ -1,6 +0,0 @@
-# frozen_string_literal: true
-module Analytics::DevopsAdoption
- def self.table_name_prefix
- 'analytics_devops_adoption_'
- end
-end
diff --git a/app/models/analytics/devops_adoption/segment.rb b/app/models/analytics/devops_adoption/segment.rb
deleted file mode 100644
index baab5b94126..00000000000
--- a/app/models/analytics/devops_adoption/segment.rb
+++ /dev/null
@@ -1,24 +0,0 @@
-# frozen_string_literal: true
-
-class Analytics::DevopsAdoption::Segment < ApplicationRecord
- ALLOWED_SEGMENT_COUNT = 20
-
- has_many :segment_selections
- has_many :groups, through: :segment_selections
-
- validates :name, presence: true, uniqueness: true, length: { maximum: 255 }
- validate :validate_segment_count, on: :create
-
- accepts_nested_attributes_for :segment_selections, allow_destroy: true
-
- scope :ordered_by_name, -> { order(:name) }
- scope :with_groups, -> { preload(:groups) }
-
- private
-
- def validate_segment_count
- if self.class.count >= ALLOWED_SEGMENT_COUNT
- errors.add(:name, s_('DevopsAdoptionSegment|The maximum number of segments has been reached'))
- end
- end
-end
diff --git a/app/models/analytics/devops_adoption/segment_selection.rb b/app/models/analytics/devops_adoption/segment_selection.rb
deleted file mode 100644
index 8f95ce088a2..00000000000
--- a/app/models/analytics/devops_adoption/segment_selection.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# frozen_string_literal: true
-
-class Analytics::DevopsAdoption::SegmentSelection < ApplicationRecord
- ALLOWED_SELECTIONS_PER_SEGMENT = 20
-
- belongs_to :segment
- belongs_to :project
- belongs_to :group
-
- validates :segment, presence: true
- validates :project, presence: { unless: :group }
- validates :project_id, uniqueness: { scope: :segment_id, if: :project }
- validates :group, presence: { unless: :project }
- validates :group_id, uniqueness: { scope: :segment_id, if: :group }
-
- validate :exclusive_project_or_group
- validate :validate_selection_count, on: :create
-
- private
-
- def exclusive_project_or_group
- if project.present? && group.present?
- errors.add(:group, s_('DevopsAdoptionSegmentSelection|The selection cannot be configured for a project and for a group at the same time'))
- end
- end
-
- def validate_selection_count
- return unless segment
-
- # handle single model creation and bulk creation from accepts_nested_attributes_for
- selections = segment.segment_selections + [self]
- if selections.reject(&:marked_for_destruction?).uniq.size > ALLOWED_SELECTIONS_PER_SEGMENT
- errors.add(:segment, s_('DevopsAdoptionSegmentSelection|The maximum number of selections has been reached'))
- end
- end
-end