Commit e1e868cb authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Update #old_version? method

Fixes this to account for the latest ID not being set yet
when this is called
parent f0527376
...@@ -505,11 +505,6 @@ class MergeRequestDiff < ApplicationRecord ...@@ -505,11 +505,6 @@ class MergeRequestDiff < ApplicationRecord
merge_request.closed? && merge_request.metrics.latest_closed_at < EXTERNAL_DIFF_CUTOFF.ago merge_request.closed? && merge_request.metrics.latest_closed_at < EXTERNAL_DIFF_CUTOFF.ago
end end
# We can't rely on `merge_request.latest_merge_request_diff_id` because that
# may have been changed in `save_git_content` without being reflected in
# the association's instance. This query is always subject to races, but
# the worst case is that we *don't* make a diff external when we could. The
# background worker will make it external at a later date.
def old_version? def old_version?
latest_id = MergeRequest latest_id = MergeRequest
.where(id: merge_request_id) .where(id: merge_request_id)
...@@ -517,7 +512,7 @@ class MergeRequestDiff < ApplicationRecord ...@@ -517,7 +512,7 @@ class MergeRequestDiff < ApplicationRecord
.pluck(:latest_merge_request_diff_id) .pluck(:latest_merge_request_diff_id)
.first .first
self.id != latest_id latest_id && self.id < latest_id
end end
def load_diffs(options) def load_diffs(options)
......
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