ProcessCommitWorker should only process commits that actually reference issues
Right now we run ProcessCommitWorker for a commit, even if it doesn't mention any issues at all. Since issues are extracted using a regular expression we can check the commit message before doing any heavy lifting in this worker.
So in other words, in perform
we'd basically do something along the lines of:
def perform(project_id, user_id, commit_hash, default = false)
project = Project.find_by(id: project_id)
return unless project
user = User.find_by(id: user_id)
return unless user
commit = build_commit(project, commit_hash)
return unless commit.message =~ Issue.reference_pattern # <-- new logic here so we don't call commit.author (which runs a DB query) unless necessary
author = commit.author || user
process_commit_message(project, commit, user, author, default)
update_issue_metrics(commit, author)
end