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
afdb0044
Commit
afdb0044
authored
Mar 22, 2021
by
Adam Hegyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert move-recursive-ns-query-to-inner-join
This reverts commit
ee1e606f
, reversing changes made to
6f95667d
.
parent
f23ed8d9
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
44 deletions
+11
-44
app/models/namespace.rb
app/models/namespace.rb
+2
-7
changelogs/unreleased/revert-inner-join-cte-fix.yml
changelogs/unreleased/revert-inner-join-cte-fix.yml
+5
-0
config/feature_flags/development/recursive_namespace_lookup_as_inner_join.yml
.../development/recursive_namespace_lookup_as_inner_join.yml
+0
-8
ee/app/models/analytics/devops_adoption/segment.rb
ee/app/models/analytics/devops_adoption/segment.rb
+1
-8
ee/spec/models/analytics/devops_adoption/segment_spec.rb
ee/spec/models/analytics/devops_adoption/segment_spec.rb
+0
-4
spec/models/namespace_spec.rb
spec/models/namespace_spec.rb
+3
-17
No files found.
app/models/namespace.rb
View file @
afdb0044
...
...
@@ -261,13 +261,8 @@ class Namespace < ApplicationRecord
# Includes projects from this namespace and projects from all subgroups
# that belongs to this namespace
def
all_projects
return
Project
.
where
(
namespace:
self
)
if
user?
if
Feature
.
enabled?
(
:recursive_namespace_lookup_as_inner_join
,
self
)
Project
.
joins
(
"INNER JOIN (
#{
self_and_descendants
.
select
(
:id
).
to_sql
}
) namespaces ON namespaces.id=projects.namespace_id"
)
else
Project
.
where
(
namespace:
self_and_descendants
)
end
namespace
=
user?
?
self
:
self_and_descendants
Project
.
where
(
namespace:
namespace
)
end
# Includes pipelines from this namespace and pipelines from all subgroups
...
...
changelogs/unreleased/revert-inner-join-cte-fix.yml
0 → 100644
View file @
afdb0044
---
title
:
Remove the recursive_namespace_lookup_as_inner_join feature flag
merge_request
:
57131
author
:
type
:
other
config/feature_flags/development/recursive_namespace_lookup_as_inner_join.yml
deleted
100644 → 0
View file @
f23ed8d9
---
name
:
recursive_namespace_lookup_as_inner_join
introduced_by_url
:
rollout_issue_url
:
milestone
:
'
13.10'
type
:
development
group
:
group::optimize
default_enabled
:
false
ee/app/models/analytics/devops_adoption/segment.rb
View file @
afdb0044
...
...
@@ -13,12 +13,5 @@ class Analytics::DevopsAdoption::Segment < ApplicationRecord
scope
:ordered_by_name
,
->
{
includes
(
:namespace
).
order
(
'"namespaces"."name" ASC'
)
}
scope
:for_namespaces
,
->
(
namespaces
)
{
where
(
namespace_id:
namespaces
)
}
scope
:for_parent
,
->
(
namespace
)
{
if
Feature
.
enabled?
(
:recursive_namespace_lookup_as_inner_join
,
namespace
)
join_sql
=
namespace
.
self_and_descendants
.
to_sql
joins
(
"INNER JOIN (
#{
join_sql
}
) namespaces ON namespaces.id=
#{
self
.
arel_table
.
name
}
.namespace_id"
)
else
for_namespaces
(
namespace
.
self_and_descendants
)
end
}
scope
:for_parent
,
->
(
namespace
)
{
for_namespaces
(
namespace
.
self_and_descendants
)
}
end
ee/spec/models/analytics/devops_adoption/segment_spec.rb
View file @
afdb0044
...
...
@@ -52,10 +52,6 @@ RSpec.describe Analytics::DevopsAdoption::Segment, type: :model do
subject
(
:segments
)
{
described_class
.
for_parent
(
group
)
}
before
do
stub_feature_flags
(
recursive_namespace_lookup_as_inner_join:
true
)
end
it
'selects segments for given namespace only'
do
expect
(
segments
).
to
match_array
([
segment1
,
segment2
])
end
...
...
spec/models/namespace_spec.rb
View file @
afdb0044
...
...
@@ -911,24 +911,10 @@ RSpec.describe Namespace do
it
{
expect
(
namespace
.
all_projects
.
to_a
).
to
match_array
([
project2
,
project1
])
}
it
{
expect
(
child
.
all_projects
.
to_a
).
to
match_array
([
project2
])
}
context
'when recursive_namespace_lookup_as_inner_join feature flag is on'
do
before
do
stub_feature_flags
(
recursive_namespace_lookup_as_inner_join:
true
)
end
it
'queries for the namespace and its descendants'
do
expect
(
namespace
.
all_projects
).
to
match_array
([
project1
,
project2
])
end
end
it
'queries for the namespace and its descendants'
do
expect
(
Project
).
to
receive
(
:where
).
with
(
namespace:
[
namespace
,
child
])
context
'when recursive_namespace_lookup_as_inner_join feature flag is off'
do
before
do
stub_feature_flags
(
recursive_namespace_lookup_as_inner_join:
false
)
end
it
'queries for the namespace and its descendants'
do
expect
(
namespace
.
all_projects
).
to
match_array
([
project1
,
project2
])
end
namespace
.
all_projects
end
end
...
...
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