Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
8f89d4b7
Commit
8f89d4b7
authored
Sep 13, 2019
by
Andreas Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable routable_two_step_lookup permanently
Closes
https://gitlab.com/gitlab-org/gitlab-ee/issues/30120
parent
a0d3691c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
36 deletions
+9
-36
app/models/concerns/routable.rb
app/models/concerns/routable.rb
+3
-17
ee/changelogs/unreleased/ab-routable-two-step-lookup-remove-feature-flag.yml
...eased/ab-routable-two-step-lookup-remove-feature-flag.yml
+5
-0
spec/models/concerns/routable_spec.rb
spec/models/concerns/routable_spec.rb
+1
-19
No files found.
app/models/concerns/routable.rb
View file @
8f89d4b7
...
...
@@ -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
...
...
ee/changelogs/unreleased/ab-routable-two-step-lookup-remove-feature-flag.yml
0 → 100644
View file @
8f89d4b7
---
title
:
Two step Routable lookup
merge_request
:
16621
author
:
type
:
performance
spec/models/concerns/routable_spec.rb
View file @
8f89d4b7
...
...
@@ -58,7 +58,7 @@ describe Group, 'Routable' do
end
end
shared_examples_for
'.find_by_full_path'
do
context
'.find_by_full_path'
do
let!
(
:nested_group
)
{
create
(
:group
,
parent:
group
)
}
context
'without any redirect routes'
do
...
...
@@ -117,24 +117,6 @@ describe Group, 'Routable' do
end
end
describe
'.find_by_full_path'
do
context
'with routable_two_step_lookup feature'
do
before
do
stub_feature_flags
(
routable_two_step_lookup:
true
)
end
it_behaves_like
'.find_by_full_path'
end
context
'without routable_two_step_lookup feature'
do
before
do
stub_feature_flags
(
routable_two_step_lookup:
false
)
end
it_behaves_like
'.find_by_full_path'
end
end
describe
'.where_full_path_in'
do
context
'without any paths'
do
it
'returns an empty relation'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment