Commit 3898c8c2 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'performance-improvements' into 'master'

Performance improvements

Push 1k commits cause 1k sql queries to collect commit author. But this variable was used only in 20 commits (from 1000).
So we did 980 sql queries without using it. This MR fixes it.

See merge request !1250
parents 53f05343 722d8073
...@@ -83,9 +83,14 @@ class GitPushService ...@@ -83,9 +83,14 @@ class GitPushService
# closing regex. Exclude any mentioned Issues from cross-referencing even if the commits are being pushed to # closing regex. Exclude any mentioned Issues from cross-referencing even if the commits are being pushed to
# a different branch. # a different branch.
issues_to_close = commit.closes_issues(project) issues_to_close = commit.closes_issues(project)
author = commit_user(commit)
if !issues_to_close.empty? && is_default_branch # Load commit author only if needed.
# For push with 1k commits it prevents 900+ requests in database
author = nil
if issues_to_close.present? && is_default_branch
author ||= commit_user(commit)
issues_to_close.each do |issue| issues_to_close.each do |issue|
Issues::CloseService.new(project, author, {}).execute(issue, commit) Issues::CloseService.new(project, author, {}).execute(issue, commit)
end end
...@@ -96,11 +101,16 @@ class GitPushService ...@@ -96,11 +101,16 @@ class GitPushService
# being pushed to a different branch). # being pushed to a different branch).
refs = commit.references(project) - issues_to_close refs = commit.references(project) - issues_to_close
refs.reject! { |r| commit.has_mentioned?(r) } refs.reject! { |r| commit.has_mentioned?(r) }
if refs.present?
author ||= commit_user(commit)
refs.each do |r| refs.each do |r|
Note.create_cross_reference_note(r, commit, author, project) Note.create_cross_reference_note(r, commit, author, project)
end end
end end
end end
end
# Produce a hash of post-receive data # Produce a hash of post-receive data
# #
......
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