diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-05 15:09:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-05 15:09:45 +0300 |
commit | 25bfb256b3bf17e85eda745d1bc193176b7fedf0 (patch) | |
tree | d1f9aa550d58b79e9d20ea403e8e13106243cfdf /app/models/merge_request | |
parent | 88ad172d0417292fc1bf70a0dfb3877a0ecb7c79 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/merge_request')
-rw-r--r-- | app/models/merge_request/metrics.rb | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/app/models/merge_request/metrics.rb b/app/models/merge_request/metrics.rb index ba363019c72..f679beabf94 100644 --- a/app/models/merge_request/metrics.rb +++ b/app/models/merge_request/metrics.rb @@ -1,10 +1,18 @@ # frozen_string_literal: true class MergeRequest::Metrics < ApplicationRecord - belongs_to :merge_request + belongs_to :merge_request, inverse_of: :metrics belongs_to :pipeline, class_name: 'Ci::Pipeline', foreign_key: :pipeline_id belongs_to :latest_closed_by, class_name: 'User' belongs_to :merged_by, class_name: 'User' + + before_save :ensure_target_project_id + + private + + def ensure_target_project_id + self.target_project_id ||= merge_request.target_project_id + end end MergeRequest::Metrics.prepend_if_ee('EE::MergeRequest::Metrics') |