debian-mirror-gitlab/app/models/releases/evidence.rb

36 lines
900 B
Ruby
Raw Normal View History

2019-12-21 20:55:43 +05:30
# frozen_string_literal: true
2020-06-23 00:09:42 +05:30
module Releases
class Evidence < ApplicationRecord
include ShaAttribute
include Presentable
2019-12-21 20:55:43 +05:30
2020-06-23 00:09:42 +05:30
belongs_to :release, inverse_of: :evidences
2019-12-21 20:55:43 +05:30
2020-06-23 00:09:42 +05:30
default_scope { order(created_at: :asc) } # rubocop:disable Cop/DefaultScope
2019-12-21 20:55:43 +05:30
2020-06-23 00:09:42 +05:30
sha_attribute :summary_sha
alias_attribute :collected_at, :created_at
alias_attribute :sha, :summary_sha
2019-12-21 20:55:43 +05:30
2020-06-23 00:09:42 +05:30
def milestones
@milestones ||= release.milestones.includes(:issues)
2020-01-03 18:37:03 +05:30
end
2020-06-23 00:09:42 +05:30
##
# Return `summary` without sensitive information.
#
# Removing issues from summary in order to prevent leaking confidential ones.
# See more https://gitlab.com/gitlab-org/gitlab/issues/121930
def summary
safe_summary = read_attribute(:summary)
2019-12-21 20:55:43 +05:30
2020-06-23 00:09:42 +05:30
safe_summary.dig('release', 'milestones')&.each do |milestone|
milestone.delete('issues')
end
2019-12-21 20:55:43 +05:30
2020-06-23 00:09:42 +05:30
safe_summary
end
2019-12-21 20:55:43 +05:30
end
end