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 ...@@ -284,9 +284,7 @@ module IssuablesHelper
end end
def issuables_count_for_state(issuable_type, state) 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: true)[state]
Gitlab::IssuablesCountForState.new(finder, store_in_redis_cache: store_in_cache)[state]
end end
def close_issuable_path(issuable) def close_issuable_path(issuable)
...@@ -442,7 +440,7 @@ module IssuablesHelper ...@@ -442,7 +440,7 @@ module IssuablesHelper
end end
def format_count(issuable_type, count, threshold) 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) format_cached_count(threshold, count)
else else
number_with_delimiter(count) number_with_delimiter(count)
......
...@@ -760,10 +760,6 @@ class Group < Namespace ...@@ -760,10 +760,6 @@ class Group < Namespace
Timelog.in_group(self) Timelog.in_group(self)
end end
def cached_issues_state_count_enabled?
Feature.enabled?(:cached_issues_state_count, self, default_enabled: :yaml)
end
def organizations def organizations
::CustomerRelations::Organization.where(group_id: self.id) ::CustomerRelations::Organization.where(group_id: self.id)
end 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,24 +83,7 @@ RSpec.describe 'Group issues page' do ...@@ -83,24 +83,7 @@ RSpec.describe 'Group issues page' do
end end
end end
context 'when project is archived' do it 'truncates issue counts if over the threshold', :clean_gitlab_redis_cache do
before do
::Projects::UpdateService.new(project, user_in_group, archived: true).execute
end
it 'does not render issue' do
visit path
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).and_call_original
allow(Rails.cache).to receive(:read).with( allow(Rails.cache).to receive(:read).with(
['group', group.id, 'issues'], ['group', group.id, 'issues'],
...@@ -111,22 +94,16 @@ RSpec.describe 'Group issues page' do ...@@ -111,22 +94,16 @@ RSpec.describe 'Group issues page' do
expect(page).to have_text('Open 1.1k Closed 500 All 1.6k') expect(page).to have_text('Open 1.1k Closed 500 All 1.6k')
end end
end
context 'when cached issues state count is disabled', :clean_gitlab_redis_cache do context 'when project is archived' do
before do before do
stub_feature_flags(cached_issues_state_count: false) ::Projects::UpdateService.new(project, user_in_group, archived: true).execute
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 end
visit issues_group_path(group) it 'does not render issue' do
visit path
expect(page).to have_text('Open 1,050 Closed 500 All 1,550') expect(page).not_to have_content issue.title[0..80]
end end
end end
end end
......
...@@ -169,22 +169,6 @@ RSpec.describe IssuablesHelper do ...@@ -169,22 +169,6 @@ RSpec.describe IssuablesHelper do
stub_const("Gitlab::IssuablesCountForState::THRESHOLD", 1000) stub_const("Gitlab::IssuablesCountForState::THRESHOLD", 1000)
end 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 it 'returns truncated count' do
expect(helper.issuables_state_counter_text(:issues, :opened, true)) 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>') .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>')
...@@ -192,7 +176,6 @@ RSpec.describe IssuablesHelper do ...@@ -192,7 +176,6 @@ RSpec.describe IssuablesHelper do
end end
end end
end end
end
describe '#issuable_reference' do describe '#issuable_reference' do
context 'when show_full_reference truthy' do context 'when show_full_reference truthy' 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