Commit 2120b071 authored by Patrick Bajao's avatar Patrick Bajao

Invalidate reviews counter cache when MR gets created

Since the "Review requests for you" counter is cached and will
only invalidate after 20 minutes, we need to invalidate the cache
when MR gets created. Doing that, we will be able to show accurate
count on the dropdown when it happens.
parent dbd28981
......@@ -158,7 +158,9 @@ class IssuableBaseService < BaseService
after_create(issuable)
execute_hooks(issuable)
invalidate_cache_counts(issuable, users: issuable.assignees)
users_to_invalidate = issuable.allows_reviewers? ? issuable.assignees | issuable.reviewers : issuable.assignees
invalidate_cache_counts(issuable, users: users_to_invalidate)
issuable.update_project_counter_caches
end
......
---
title: Invalidate reviews counter cache when MR gets created
merge_request: 51316
author:
type: fixed
......@@ -155,6 +155,12 @@ RSpec.describe MergeRequests::CreateService, :clean_gitlab_redis_shared_state do
expect(Todo.where(attributes).count).to eq 1
end
it 'invalidates counter cache for reviewers', :use_clean_rails_memory_store_caching do
expect { merge_request }
.to change { user2.review_requested_open_merge_requests_count }
.by(1)
end
end
context 'when head pipelines already exist for merge request source branch', :sidekiq_inline 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