2018-11-08 19:23:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-03 12:29:30 +05:30
|
|
|
class UpdateMergeRequestsWorker
|
2018-03-17 18:26:18 +05:30
|
|
|
include ApplicationWorker
|
|
|
|
|
2019-12-21 20:55:43 +05:30
|
|
|
feature_category :source_code_management
|
2019-12-26 22:10:19 +05:30
|
|
|
latency_sensitive_worker!
|
|
|
|
worker_resource_boundary :cpu
|
2020-03-09 13:42:32 +05:30
|
|
|
weight 3
|
2019-12-21 20:55:43 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
LOG_TIME_THRESHOLD = 90 # seconds
|
2016-11-03 12:29:30 +05:30
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-11-03 12:29:30 +05:30
|
|
|
def perform(project_id, user_id, oldrev, newrev, ref)
|
|
|
|
project = Project.find_by(id: project_id)
|
|
|
|
return unless project
|
|
|
|
|
|
|
|
user = User.find_by(id: user_id)
|
|
|
|
return unless user
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
# TODO: remove this benchmarking when we have rich logging
|
|
|
|
time = Benchmark.measure do
|
|
|
|
MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref)
|
|
|
|
end
|
|
|
|
|
|
|
|
args_log = [
|
|
|
|
"elapsed=#{time.real}",
|
|
|
|
"project_id=#{project_id}",
|
|
|
|
"user_id=#{user_id}",
|
|
|
|
"oldrev=#{oldrev}",
|
|
|
|
"newrev=#{newrev}",
|
|
|
|
"ref=#{ref}"
|
|
|
|
].join(',')
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
Rails.logger.info("UpdateMergeRequestsWorker#perform #{args_log}") if time.real > LOG_TIME_THRESHOLD # rubocop:disable Gitlab/RailsLogger
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-11-03 12:29:30 +05:30
|
|
|
end
|