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>2024-01-16 13:42:19 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2024-01-16 13:42:19 +0300
commit84d1bd786125c1c14a3ba5f63e38a4cc736a9027 (patch)
treef550fa965f507077e20dbb6d61a8269a99ef7107 /app/models/concerns/routable.rb
parent3a105e36e689f7b75482236712f1a47fd5a76814 (diff)
Add latest changes from gitlab-org/gitlab@16-8-stable-eev16.8.0-rc42
Diffstat (limited to 'app/models/concerns/routable.rb')
-rw-r--r--app/models/concerns/routable.rb36
1 files changed, 13 insertions, 23 deletions
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index 242194be440..43874d0211c 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -87,37 +87,27 @@ module Routable
# Klass.where_full_path_in(%w{gitlab-org/gitlab-foss gitlab-org/gitlab})
#
# Returns an ActiveRecord::Relation.
- def where_full_path_in(paths, use_includes: true)
+ def where_full_path_in(paths, preload_routes: true)
return none if paths.empty?
- wheres = paths.map do |path|
+ path_condition = paths.map do |path|
"(LOWER(routes.path) = LOWER(#{connection.quote(path)}))"
- end
+ end.join(' OR ')
- if Feature.enabled?(:optimize_where_full_path_in, Feature.current_request)
- route_scope = all
- source_type_condition = { source_type: route_scope.klass.base_class }
+ route_scope = all
+ source_type_condition = { source_type: route_scope.klass.base_class }
- routes_matching_condition = Route.where(source_type_condition).where(wheres.join(' OR '))
+ routes_matching_condition = Route
+ .where(source_type_condition)
+ .where(path_condition)
- result = route_scope.where(id: routes_matching_condition.pluck(:source_id))
+ source_ids = routes_matching_condition.pluck(:source_id)
+ result = route_scope.where(id: source_ids)
- if use_includes
- result.preload(:route)
- else
- result
- end
+ if preload_routes
+ result.preload(:route)
else
- route =
- if use_includes
- includes(:route).references(:routes)
- else
- joins(:route)
- end
-
- route
- .where(wheres.join(' OR '))
- .allow_cross_joins_across_databases(url: "https://gitlab.com/gitlab-org/gitlab/-/issues/420046")
+ result
end
end
end