diff options
author | Sean McGivern <sean@gitlab.com> | 2017-10-26 13:33:54 +0300 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2017-11-02 19:09:56 +0300 |
commit | 4768a1e26f70263be24ac681042507fe01218b9b (patch) | |
tree | 782bed589e0e7f87b5b665a56a4986c7dd7fc9e8 /app | |
parent | d8299e320ec8c93311f678ed4dddab66528d021e (diff) |
Set merge_request_diff_id on MR when creating
Once we migrate existing MRs to have this column, we will be able to get the
latest diff for a single merge request more efficiently, and (more importantly)
get all latest diffs for a collection of MRs efficiently.
Diffstat (limited to 'app')
-rw-r--r-- | app/models/merge_request_diff.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb index faf0b95f842..1eda0f9cbbd 100644 --- a/app/models/merge_request_diff.rb +++ b/app/models/merge_request_diff.rb @@ -48,6 +48,10 @@ class MergeRequestDiff < ActiveRecord::Base # Collect information about commits and diff from repository # and save it to the database as serialized data def save_git_content + MergeRequest + .where('id = ? AND COALESCE(latest_merge_request_diff_id, 0) < ?', self.merge_request_id, self.id) + .update_all(latest_merge_request_diff_id: self.id) + ensure_commit_shas save_commits save_diffs |