diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/models/release.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/models/release.rb')
-rw-r--r-- | app/models/release.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/models/release.rb b/app/models/release.rb index 5ca8f537baa..1889a0707b4 100644 --- a/app/models/release.rb +++ b/app/models/release.rb @@ -13,6 +13,7 @@ class Release < ApplicationRecord belongs_to :author, class_name: 'User' has_many :links, class_name: 'Releases::Link' + has_many :sorted_links, -> { sorted }, class_name: 'Releases::Link', inverse_of: :release has_many :milestone_releases has_many :milestones, through: :milestone_releases @@ -23,11 +24,15 @@ class Release < ApplicationRecord before_create :set_released_at validates :project, :tag, presence: true + validates :description, length: { maximum: Gitlab::Database::MAX_TEXT_SIZE_LIMIT }, if: :description_changed? validates_associated :milestone_releases, message: -> (_, obj) { obj[:value].map(&:errors).map(&:full_messages).join(",") } validates :links, nested_attributes_duplicates: { scope: :release, child_attributes: %i[name url filepath] } scope :sorted, -> { order(released_at: :desc) } - scope :preloaded, -> { includes(:evidences, :milestones, project: [:project_feature, :route, { namespace: :route }]) } + scope :preloaded, -> { + includes(:author, :evidences, :milestones, :links, :sorted_links, + project: [:project_feature, :route, { namespace: :route }]) + } scope :with_project_and_namespace, -> { includes(project: :namespace) } scope :recent, -> { sorted.limit(MAX_NUMBER_TO_DISPLAY) } scope :without_evidence, -> { left_joins(:evidences).where(::Releases::Evidence.arel_table[:id].eq(nil)) } @@ -58,8 +63,8 @@ class Release < ApplicationRecord end def assets_count(except: []) - links_count = links.count - sources_count = except.include?(:sources) ? 0 : sources.count + links_count = links.size + sources_count = except.include?(:sources) ? 0 : sources.size links_count + sources_count end @@ -123,4 +128,4 @@ class Release < ApplicationRecord end end -Release.prepend_if_ee('EE::Release') +Release.prepend_mod_with('Release') |