Read about our upcoming Code of Conduct on this issue

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

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 16a56a3f796c
......@@ -48,6 +48,10 @@ def st_commits
# 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