Commit ff79b67f authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch '333089-remove-cached-issues-state-count-ff' into 'master'

Removes `cached_issues_state_count` feature flag

See merge request gitlab-org/gitlab!72516
parents 54cf5455 d5802c91
......@@ -284,9 +284,7 @@ module IssuablesHelper
end
def issuables_count_for_state(issuable_type, state)
store_in_cache = parent.is_a?(Group) ? parent.cached_issues_state_count_enabled? : false
Gitlab::IssuablesCountForState.new(finder, store_in_redis_cache: store_in_cache)[state]
Gitlab::IssuablesCountForState.new(finder, store_in_redis_cache: true)[state]
end
def close_issuable_path(issuable)
......@@ -442,7 +440,7 @@ module IssuablesHelper
end
def format_count(issuable_type, count, threshold)
if issuable_type == :issues && parent.is_a?(Group) && parent.cached_issues_state_count_enabled?
if issuable_type == :issues && parent.is_a?(Group)
format_cached_count(threshold, count)
else
number_with_delimiter(count)
......
......@@ -760,10 +760,6 @@ class Group < Namespace
Timelog.in_group(self)
end
def cached_issues_state_count_enabled?
Feature.enabled?(:cached_issues_state_count, self, default_enabled: :yaml)
end
def organizations
::CustomerRelations::Organization.where(group_id: self.id)
end
......
---
name: cached_issues_state_count
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/67418
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/333089
milestone: '14.3'
type: development
group: group::product planning
default_enabled: false
......@@ -83,6 +83,18 @@ RSpec.describe 'Group issues page' do
end
end
it 'truncates issue counts if over the threshold', :clean_gitlab_redis_cache do
allow(Rails.cache).to receive(:read).and_call_original
allow(Rails.cache).to receive(:read).with(
['group', group.id, 'issues'],
{ expires_in: Gitlab::IssuablesCountForState::CACHE_EXPIRES_IN }
).and_return({ opened: 1050, closed: 500, all: 1550 })
visit issues_group_path(group)
expect(page).to have_text('Open 1.1k Closed 500 All 1.6k')
end
context 'when project is archived' do
before do
::Projects::UpdateService.new(project, user_in_group, archived: true).execute
......@@ -94,41 +106,6 @@ RSpec.describe 'Group issues page' do
expect(page).not_to have_content issue.title[0..80]
end
end
context 'when cached issues state count is enabled', :clean_gitlab_redis_cache do
before do
stub_feature_flags(cached_issues_state_count: true)
end
it 'truncates issue counts if over the threshold' do
allow(Rails.cache).to receive(:read).and_call_original
allow(Rails.cache).to receive(:read).with(
['group', group.id, 'issues'],
{ expires_in: Gitlab::IssuablesCountForState::CACHE_EXPIRES_IN }
).and_return({ opened: 1050, closed: 500, all: 1550 })
visit issues_group_path(group)
expect(page).to have_text('Open 1.1k Closed 500 All 1.6k')
end
end
context 'when cached issues state count is disabled', :clean_gitlab_redis_cache do
before do
stub_feature_flags(cached_issues_state_count: false)
end
it 'does not truncate counts if they are over the threshold' do
allow_next_instance_of(IssuesFinder) do |finder|
allow(finder).to receive(:count_by_state).and_return(true)
.and_return({ opened: 1050, closed: 500, all: 1550 })
end
visit issues_group_path(group)
expect(page).to have_text('Open 1,050 Closed 500 All 1,550')
end
end
end
context 'projects with issues disabled' do
......
......@@ -169,26 +169,9 @@ RSpec.describe IssuablesHelper do
stub_const("Gitlab::IssuablesCountForState::THRESHOLD", 1000)
end
context 'when feature flag cached_issues_state_count is disabled' do
before do
stub_feature_flags(cached_issues_state_count: false)
end
it 'returns complete count' do
expect(helper.issuables_state_counter_text(:issues, :opened, true))
.to eq('<span>Open</span> <span class="badge badge-muted badge-pill gl-badge gl-tab-counter-badge sm gl-display-none gl-sm-display-inline-flex">1,100</span>')
end
end
context 'when feature flag cached_issues_state_count is enabled' do
before do
stub_feature_flags(cached_issues_state_count: true)
end
it 'returns truncated count' do
expect(helper.issuables_state_counter_text(:issues, :opened, true))
.to eq('<span>Open</span> <span class="badge badge-muted badge-pill gl-badge gl-tab-counter-badge sm gl-display-none gl-sm-display-inline-flex">1.1k</span>')
end
it 'returns truncated count' do
expect(helper.issuables_state_counter_text(:issues, :opened, true))
.to eq('<span>Open</span> <span class="badge badge-muted badge-pill gl-badge gl-tab-counter-badge sm gl-display-none gl-sm-display-inline-flex">1.1k</span>')
end
end
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