Commit 560ae1db authored by Pavel Shutsin's avatar Pavel Shutsin

Don't recalculate approval metrics on approval remove

Even of approval happened regardless if it was removed
immediately after or not. We shouldn't mess data
with recalculation.
parent 2e668587
...@@ -14,7 +14,6 @@ module MergeRequests ...@@ -14,7 +14,6 @@ module MergeRequests
if approval.destroy_all # rubocop: disable DestroyAll if approval.destroy_all # rubocop: disable DestroyAll
merge_request.reset_approval_cache! merge_request.reset_approval_cache!
create_note(merge_request) create_note(merge_request)
recalculate_approvals_metrics(merge_request)
if currently_approved if currently_approved
notification_service.async.unapprove_mr(merge_request, current_user) notification_service.async.unapprove_mr(merge_request, current_user)
...@@ -31,11 +30,5 @@ module MergeRequests ...@@ -31,11 +30,5 @@ module MergeRequests
def create_note(merge_request) def create_note(merge_request)
SystemNoteService.unapprove_mr(merge_request, current_user) SystemNoteService.unapprove_mr(merge_request, current_user)
end end
def recalculate_approvals_metrics(merge_request)
return unless merge_request.project.feature_available?(:code_review_analytics)
Analytics::RefreshApprovalsData.new(merge_request).execute_async(force: true)
end
end end
end end
---
title: Remove approval metric recalculation when approval was removed
merge_request: 27071
author:
type: changed
...@@ -50,33 +50,6 @@ describe MergeRequests::RemoveApprovalService do ...@@ -50,33 +50,6 @@ describe MergeRequests::RemoveApprovalService do
execute! execute!
end end
context 'approvals metrics calculation' do
context 'when code_review_analytics project feature is available' do
before do
stub_licensed_features(code_review_analytics: true)
end
it 'schedules RefreshApprovalsData' do
expect(Analytics::CodeReviewMetricsWorker)
.to receive(:perform_async).with('Analytics::RefreshApprovalsData', merge_request.id, force: true)
service.execute(merge_request)
end
end
context 'when code_review_analytics is not available' do
before do
stub_licensed_features(code_review_analytics: false)
end
it 'does not schedule for RefreshApprovalsData' do
expect(Analytics::CodeReviewMetricsWorker).not_to receive(:perform_async)
service.execute(merge_request)
end
end
end
end end
context 'with an approved merge request' do context 'with an approved merge request' do
......
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