Skip to content
Snippets Groups Projects
Commit 38cee0a3 authored by Mark Chao's avatar Mark Chao :two:
Browse files

Clear approval state caching after update

This is to recompute the new overall_approvers
In this method, the following calls would cause a change in the
database which needs resetting the cache:

- super (which updates MR)
- sync_approval_rules (which updates rule record's approvals_required)
- cleanup_approvers (which removes any approver not mentioned in params)

resetting cache must be done after those three calls,
so moving some calls earlier is required.
However this would not affect outcome.
parent 954f7c73
No related branches found
No related tags found
1 merge request!8769[API] Approval rule endpoints
......@@ -13,6 +13,13 @@ def execute(merge_request)
old_approvers = merge_request.overall_approvers(exclude_code_owners: true)
merge_request = super(merge_request)
sync_approval_rules(merge_request)
if should_remove_old_approvers && merge_request.valid?
cleanup_approvers(merge_request, reload: true)
end
merge_request.reset_approval_cache!
new_approvers = merge_request.overall_approvers(exclude_code_owners: true) - old_approvers
......@@ -21,12 +28,6 @@ def execute(merge_request)
notification_service.add_merge_request_approvers(merge_request, new_approvers, current_user)
end
if should_remove_old_approvers && merge_request.valid?
cleanup_approvers(merge_request, reload: true)
end
sync_approval_rules(merge_request)
merge_request
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment