Commit 4768a1e2 authored by Sean McGivern's avatar Sean McGivern

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.
parent d8299e32
......@@ -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
......
---
title: Make finding most recent merge request diffs more efficient
title: Add a latest_merge_request_diff_id column to merge_requests
merge_request: 15035
author:
type: performance
......@@ -113,7 +113,7 @@ excluded_attributes:
- :milestone_id
- :ref_fetched
- :merge_jid
- :merge_request_diff_id
- :latest_merge_request_diff_id
award_emoji:
- :awardable_id
statuses:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment