Commit 71af5b0c authored by Pavel Shutsin's avatar Pavel Shutsin

Fix CodeReviewMetrics worker failure with kwargs

It appears that Sidekiq does not support jobs with
keyword arguments. See link below for details:
https://github.com/mperham/sidekiq/issues/2372
parent 6a739930
......@@ -8,12 +8,12 @@ module Analytics
idempotent!
def perform(operation, merge_request_id, **execute_args)
def perform(operation, merge_request_id, execute_kwargs = {})
::MergeRequest.find_by_id(merge_request_id).try do |merge_request|
break unless merge_request.project.feature_available?(:code_review_analytics)
operation_klass = operation.constantize
operation_klass.new(merge_request).execute(**execute_args)
operation_klass.new(merge_request).execute(**execute_kwargs.deep_symbolize_keys)
end
end
end
......
......@@ -16,9 +16,9 @@ module Analytics
end
end
def execute_async(*args)
def execute_async(**kwargs)
merge_requests.each do |mr|
CodeReviewMetricsWorker.perform_async(self.class.name, mr.id, *args)
CodeReviewMetricsWorker.perform_async(self.class.name, mr.id, **kwargs)
end
end
......
......@@ -98,7 +98,7 @@ describe MergeRequests::ApprovalService do
it 'schedules RefreshApprovalsData' do
expect(Analytics::CodeReviewMetricsWorker)
.to receive(:perform_async).with('Analytics::RefreshApprovalsData', merge_request.id)
.to receive(:perform_async).with('Analytics::RefreshApprovalsData', merge_request.id, {})
service.execute(merge_request)
end
......
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