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:
Diffstat (limited to 'app/models/concerns/routable.rb')
-rw-r--r--app/models/concerns/routable.rb29
1 files changed, 22 insertions, 7 deletions
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb
index 4c16ba18823..242194be440 100644
--- a/app/models/concerns/routable.rb
+++ b/app/models/concerns/routable.rb
@@ -94,16 +94,31 @@ module Routable
"(LOWER(routes.path) = LOWER(#{connection.quote(path)}))"
end
- route =
+ if Feature.enabled?(:optimize_where_full_path_in, Feature.current_request)
+ 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 '))
+
+ result = route_scope.where(id: routes_matching_condition.pluck(:source_id))
+
if use_includes
- includes(:route).references(:routes)
+ result.preload(:route)
else
- joins(:route)
+ result
end
-
- route
- .where(wheres.join(' OR '))
- .allow_cross_joins_across_databases(url: "https://gitlab.com/gitlab-org/gitlab/-/issues/420046")
+ 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")
+ end
end
end