Commit fcd232b7 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch '325470-optimize-confidentiality-filter-on-issue-finder' into 'master'

Optimize IssuesFinder redundent confidential check when assigned [RUN ALL RSPEC] [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!57073
parents 58a8881c f0e07c6b
......@@ -47,6 +47,15 @@ class IssuesFinder < IssuableFinder
# rubocop: disable CodeReuse/ActiveRecord
def with_confidentiality_access_check
return Issue.all if params.user_can_see_all_confidential_issues?
if Feature.enabled?(:optimize_issue_filter_assigned_to_self, default_enabled: :yaml)
# If already filtering by assignee we can skip confidentiality since a user
# can always see confidential issues assigned to them. This is just an
# optimization since a very common usecase of this Finder is to load the
# count of issues assigned to the user for the header bar.
return Issue.all if current_user && params.assignees.include?(current_user)
end
return Issue.where('issues.confidential IS NOT TRUE') if params.user_cannot_see_confidential_issues?
Issue.where('
......
---
title: Optimize database performance of loading assigned issue count on header bar
merge_request: 57073
author:
type: performance
---
name: optimize_issue_filter_assigned_to_self
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/57073
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/325470
milestone: '13.11'
type: development
group: group::global search
default_enabled: false
# frozen_string_literal: true
RSpec.shared_examples 'assignee ID filter' do
context 'when optimize_issue_filter_assigned_to_self is disabled' do
before do
stub_feature_flags(optimize_issue_filter_assigned_to_self: false)
end
it 'returns issuables assigned to that user' do
expect(issuables).to contain_exactly(*expected_issuables)
end
end
it 'returns issuables assigned to that user' do
expect(issuables).to contain_exactly(*expected_issuables)
end
......@@ -13,6 +23,16 @@ RSpec.shared_examples 'assignee NOT ID filter' do
end
RSpec.shared_examples 'assignee username filter' do
context 'when optimize_issue_filter_assigned_to_self is disabled' do
before do
stub_feature_flags(optimize_issue_filter_assigned_to_self: false)
end
it 'returns issuables assigned to those users' do
expect(issuables).to contain_exactly(*expected_issuables)
end
end
it 'returns issuables assigned to those users' do
expect(issuables).to contain_exactly(*expected_issuables)
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