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-11-06 00:08:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-11-06 00:08:51 +0300
commit1bc5af76617026dec53016cb0881ec834ccab807 (patch)
treed0bd460cfcf415248441a1ad79a8bf76b87aa27d /app/models/analytics
parent3e1c760141a27097d74d191a619fa6edecd86fe7 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/analytics')
-rw-r--r--app/models/analytics/devops_adoption/segment.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/analytics/devops_adoption/segment.rb b/app/models/analytics/devops_adoption/segment.rb
index e679d5ab71c..71d4a312627 100644
--- a/app/models/analytics/devops_adoption/segment.rb
+++ b/app/models/analytics/devops_adoption/segment.rb
@@ -4,10 +4,16 @@ 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
+ 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