2018-06-27 03:23:28 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-10-10 03:40:14 -04:00
|
|
|
class UpdateMergeRequestsWorker
|
2017-11-28 11:08:30 -05:00
|
|
|
include ApplicationWorker
|
2016-10-10 03:40:14 -04:00
|
|
|
|
2017-11-14 09:22:15 -05:00
|
|
|
LOG_TIME_THRESHOLD = 90 # seconds
|
|
|
|
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2016-10-10 03:40:14 -04:00
|
|
|
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
|
|
|
|
|
2017-11-13 14:56:08 -05:00
|
|
|
# TODO: remove this benchmarking when we have rich logging
|
|
|
|
time = Benchmark.measure do
|
|
|
|
MergeRequests::RefreshService.new(project, user).execute(oldrev, newrev, ref)
|
|
|
|
end
|
|
|
|
|
2017-11-14 09:22:15 -05:00
|
|
|
args_log = [
|
|
|
|
"elapsed=#{time.real}",
|
|
|
|
"project_id=#{project_id}",
|
|
|
|
"user_id=#{user_id}",
|
|
|
|
"oldrev=#{oldrev}",
|
|
|
|
"newrev=#{newrev}",
|
|
|
|
"ref=#{ref}"
|
|
|
|
].join(',')
|
2017-11-13 14:56:08 -05:00
|
|
|
|
2019-07-10 15:26:47 -04:00
|
|
|
Rails.logger.info("UpdateMergeRequestsWorker#perform #{args_log}") if time.real > LOG_TIME_THRESHOLD # rubocop:disable Gitlab/RailsLogger
|
2016-10-10 03:40:14 -04:00
|
|
|
end
|
2018-08-27 11:31:01 -04:00
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2016-10-10 03:40:14 -04:00
|
|
|
end
|