diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-16 21:06:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-09-16 21:06:05 +0300 |
commit | 930ff68c1efc380cb7522aa9b3884842eecb2486 (patch) | |
tree | 208f21205f9c8ee90e9722c6f641169d9a1569bf /app/models/concerns/routable.rb | |
parent | 84727c8209a4412e21111a07f99b0438b03232de (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/concerns/routable.rb')
-rw-r--r-- | app/models/concerns/routable.rb | 20 |
1 files changed, 3 insertions, 17 deletions
diff --git a/app/models/concerns/routable.rb b/app/models/concerns/routable.rb index 8b011bca72c..57118bf7a6b 100644 --- a/app/models/concerns/routable.rb +++ b/app/models/concerns/routable.rb @@ -33,16 +33,9 @@ module Routable # # Returns a single object, or nil. def find_by_full_path(path, follow_redirects: false) - routable_calls_counter.increment(method: 'find_by_full_path') - - if Feature.enabled?(:routable_two_step_lookup) - # Case sensitive match first (it's cheaper and the usual case) - # If we didn't have an exact match, we perform a case insensitive search - found = includes(:route).find_by(routes: { path: path }) || where_full_path_in([path]).take - else - order_sql = Arel.sql("(CASE WHEN routes.path = #{connection.quote(path)} THEN 0 ELSE 1 END)") - found = where_full_path_in([path]).reorder(order_sql).take - end + # Case sensitive match first (it's cheaper and the usual case) + # If we didn't have an exact match, we perform a case insensitive search + found = includes(:route).find_by(routes: { path: path }) || where_full_path_in([path]).take return found if found @@ -61,19 +54,12 @@ module Routable def where_full_path_in(paths) return none if paths.empty? - routable_calls_counter.increment(method: 'where_full_path_in') - wheres = paths.map do |path| "(LOWER(routes.path) = LOWER(#{connection.quote(path)}))" end includes(:route).where(wheres.join(' OR ')).references(:routes) end - - # Temporary instrumentation of method calls - def routable_calls_counter - @routable_calls_counter ||= Gitlab::Metrics.counter(:gitlab_routable_calls_total, 'Number of calls to Routable by method') - end end def full_name |