Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-09-20 14:18:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-09-20 14:18:08 +0300
commit5afcbe03ead9ada87621888a31a62652b10a7e4f (patch)
tree9918b67a0d0f0bafa6542e839a8be37adf73102d /lib/gitlab/search_results.rb
parentc97c0201564848c1f53226fe19d71fdcc472f7d0 (diff)
Add latest changes from gitlab-org/gitlab@16-4-stable-eev16.4.0-rc42
Diffstat (limited to 'lib/gitlab/search_results.rb')
-rw-r--r--lib/gitlab/search_results.rb33
1 files changed, 17 insertions, 16 deletions
diff --git a/lib/gitlab/search_results.rb b/lib/gitlab/search_results.rb
index 0e419d0162c..35e01101b3b 100644
--- a/lib/gitlab/search_results.rb
+++ b/lib/gitlab/search_results.rb
@@ -181,10 +181,7 @@ module Gitlab
def projects
scope = limit_projects
-
- if Feature.enabled?(:search_projects_hide_archived, current_user) && !filters[:include_archived]
- scope = scope.non_archived
- end
+ scope = scope.non_archived unless filters[:include_archived]
scope.search(query)
end
@@ -193,8 +190,13 @@ module Gitlab
issues = IssuesFinder.new(current_user, issuable_params.merge(finder_params)).execute
unless default_project_filter
- issues = issues.in_projects(project_ids_relation)
- .allow_cross_joins_across_databases(url: "https://gitlab.com/gitlab-org/gitlab/-/issues/420046")
+ project_ids = project_ids_relation
+ if Feature.enabled?(:search_issues_hide_archived_projects, current_user) && !filters[:include_archived]
+ project_ids = project_ids.non_archived
+ end
+
+ issues = issues.in_projects(project_ids)
+ .allow_cross_joins_across_databases(url: 'https://gitlab.com/gitlab-org/gitlab/-/issues/420046')
end
apply_sort(issues, scope: 'issues')
@@ -233,22 +235,21 @@ module Gitlab
# Filter milestones by authorized projects.
# For performance reasons project_id is being plucked
# to be used on a smaller query.
- #
- # rubocop: disable CodeReuse/ActiveRecord
def filter_milestones_by_project(milestones)
- project_ids =
- milestones.where(project_id: project_ids_relation)
- .select(:project_id).distinct
- .pluck(:project_id)
+ candidate_project_ids = project_ids_relation
+
+ if Feature.enabled?(:search_milestones_hide_archived_projects, current_user) && !filters[:include_archived]
+ candidate_project_ids = candidate_project_ids.non_archived
+ end
+
+ project_ids = milestones.of_projects(candidate_project_ids).select(:project_id).distinct.pluck(:project_id) # rubocop: disable CodeReuse/ActiveRecord
return Milestone.none if project_ids.nil?
- authorized_project_ids_relation =
- Project.where(id: project_ids).ids_with_issuables_available_for(current_user)
+ authorized_project_ids_relation = Project.id_in(project_ids).ids_with_issuables_available_for(current_user)
- milestones.where(project_id: authorized_project_ids_relation)
+ milestones.of_projects(authorized_project_ids_relation)
end
- # rubocop: enable CodeReuse/ActiveRecord
# rubocop: disable CodeReuse/ActiveRecord
def project_ids_relation