summaryrefslogtreecommitdiff
path: root/app/models/merge_request_diff.rb
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2019-04-08 15:33:36 +0200
committerKamil Trzciński <ayufan@ayufan.eu>2019-04-15 13:05:14 +0200
commit650f40865e5d8136cb366fbde689c4100aafb0c5 (patch)
treef740d9f235693ad8e2a3693d6ec30dee26d2a74a /app/models/merge_request_diff.rb
parent7457c1e1229cd1e90e608e8b247e2fbb217f05b6 (diff)
downloadgitlab-ce-650f40865e5d8136cb366fbde689c4100aafb0c5.tar.gz
Forbid the use of `#reload` and prefer `#reset`forbid-the-usage-of-reload
The `#reload` makes to load all objects into memory, and the main purpose of `#reload` is to drop the association cache. The `#reset` seems to solve exactly that case.
Diffstat (limited to 'app/models/merge_request_diff.rb')
-rw-r--r--app/models/merge_request_diff.rb6
1 files changed, 3 insertions, 3 deletions
diff --git a/app/models/merge_request_diff.rb b/app/models/merge_request_diff.rb
index ac8d3b98266..0b787217410 100644
--- a/app/models/merge_request_diff.rb
+++ b/app/models/merge_request_diff.rb
@@ -387,7 +387,7 @@ class MergeRequestDiff < ApplicationRecord
save!
end
- merge_request_diff_files.reload
+ merge_request_diff_files.reset
end
private
@@ -541,10 +541,10 @@ class MergeRequestDiff < ApplicationRecord
def save_commits
MergeRequestDiffCommit.create_bulk(self.id, compare.commits.reverse)
- # merge_request_diff_commits.reload is preferred way to reload associated
+ # merge_request_diff_commits.reset is preferred way to reload associated
# objects but it returns cached result for some reason in this case
# we can circumvent that by specifying that we need an uncached reload
- commits = self.class.uncached { merge_request_diff_commits.reload }
+ commits = self.class.uncached { merge_request_diff_commits.reset }
self.commits_count = commits.size
end