Skip to content
Snippets Groups Projects

Cache the commit author in RequestStore to avoid extra lookups in PostReceive

Merged Stan Hu requested to merge stanhu/gitlab-ce:cache-commit-author-lookup into master
1 unresolved thread
3 files
+ 37
1
Compare changes
  • Side-by-side
  • Inline
Files
3
+ 16
1
@@ -178,7 +178,18 @@ class Commit
end
def author
@author ||= User.find_by_any_email(author_email.downcase)
if RequestStore.active?
key = "commit_author:#{author_email.downcase}"
# nil is a valid value since no author may exist in the system
if RequestStore.store.has_key?(key)
@author = RequestStore.store[key]
else
@author = find_author_by_any_email
RequestStore.store[key] = @author
end
Please register or sign in to reply
else
@author ||= find_author_by_any_email
end
end
def committer
@@ -306,6 +317,10 @@ class Commit
private
def find_author_by_any_email
User.find_by_any_email(author_email.downcase)
end
def repo_changes
changes = { added: [], modified: [], removed: [] }
Loading