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
be18a735
Commit
be18a735
authored
Aug 12, 2021
by
Heinrich Lee Yu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Merge branch '337719-linear-project-ancestors' into 'master'"
This reverts merge request !67565
parent
61975014
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
9 additions
and
57 deletions
+9
-57
app/models/integration.rb
app/models/integration.rb
+1
-1
app/models/namespaces/traversal/linear.rb
app/models/namespaces/traversal/linear.rb
+0
-4
app/models/project.rb
app/models/project.rb
+1
-3
ee/spec/helpers/projects/project_members_helper_spec.rb
ee/spec/helpers/projects/project_members_helper_spec.rb
+1
-1
spec/models/project_spec.rb
spec/models/project_spec.rb
+6
-48
No files found.
app/models/integration.rb
View file @
be18a735
...
@@ -274,7 +274,7 @@ class Integration < ApplicationRecord
...
@@ -274,7 +274,7 @@ class Integration < ApplicationRecord
end
end
def
self
.
closest_group_integration
(
type
,
scope
)
def
self
.
closest_group_integration
(
type
,
scope
)
group_ids
=
scope
.
ancestors
(
hierarchy_order: :asc
)
.
select
(
:id
)
group_ids
=
scope
.
ancestors
.
select
(
:id
)
array
=
group_ids
.
to_sql
.
present?
?
"array(
#{
group_ids
.
to_sql
}
)"
:
'ARRAY[]'
array
=
group_ids
.
to_sql
.
present?
?
"array(
#{
group_ids
.
to_sql
}
)"
:
'ARRAY[]'
where
(
type:
type
,
group_id:
group_ids
,
inherit_from_id:
nil
)
where
(
type:
type
,
group_id:
group_ids
,
inherit_from_id:
nil
)
...
...
app/models/namespaces/traversal/linear.rb
View file @
be18a735
...
@@ -178,10 +178,6 @@ module Namespaces
...
@@ -178,10 +178,6 @@ module Namespaces
depth_sql
=
"ABS(
#{
traversal_ids
.
count
}
- array_length(traversal_ids, 1))"
depth_sql
=
"ABS(
#{
traversal_ids
.
count
}
- array_length(traversal_ids, 1))"
skope
=
skope
.
select
(
skope
.
arel_table
[
Arel
.
star
],
"
#{
depth_sql
}
as depth"
)
skope
=
skope
.
select
(
skope
.
arel_table
[
Arel
.
star
],
"
#{
depth_sql
}
as depth"
)
.
order
(
depth:
hierarchy_order
)
.
order
(
depth:
hierarchy_order
)
# The SELECT includes an extra depth attribute. We then wrap the SQL
# in a standard SELECT to avoid mismatched attribute errors when
# trying to chain future ActiveRelation commands.
skope
=
self
.
class
.
without_sti_condition
.
from
(
skope
,
self
.
class
.
table_name
)
end
end
skope
skope
...
...
app/models/project.rb
View file @
be18a735
...
@@ -914,9 +914,7 @@ class Project < ApplicationRecord
...
@@ -914,9 +914,7 @@ class Project < ApplicationRecord
.
base_and_ancestors
(
upto:
top
,
hierarchy_order:
hierarchy_order
)
.
base_and_ancestors
(
upto:
top
,
hierarchy_order:
hierarchy_order
)
end
end
def
ancestors
(
hierarchy_order:
nil
)
alias_method
:ancestors
,
:ancestors_upto
namespace
&
.
self_and_ancestors
(
hierarchy_order:
hierarchy_order
)
end
def
ancestors_upto_ids
(
...
)
def
ancestors_upto_ids
(
...
)
ancestors_upto
(
...
).
pluck
(
:id
)
ancestors_upto
(
...
).
pluck
(
:id
)
...
...
ee/spec/helpers/projects/project_members_helper_spec.rb
View file @
be18a735
...
@@ -33,7 +33,7 @@ RSpec.describe Projects::ProjectMembersHelper do
...
@@ -33,7 +33,7 @@ RSpec.describe Projects::ProjectMembersHelper do
expect
(
project
.
members
.
count
).
to
eq
(
3
)
expect
(
project
.
members
.
count
).
to
eq
(
3
)
expect
{
call_project_members_app_data_json
}.
not_to
exceed_query_limit
(
control_count
).
with_threshold
(
7
)
# existing n+1
expect
{
call_project_members_app_data_json
}.
not_to
exceed_query_limit
(
control_count
).
with_threshold
(
6
)
# existing n+1
end
end
end
end
...
...
spec/models/project_spec.rb
View file @
be18a735
...
@@ -6,7 +6,6 @@ RSpec.describe Project, factory_default: :keep do
...
@@ -6,7 +6,6 @@ RSpec.describe Project, factory_default: :keep do
include
ProjectForksHelper
include
ProjectForksHelper
include
GitHelpers
include
GitHelpers
include
ExternalAuthorizationServiceHelpers
include
ExternalAuthorizationServiceHelpers
include
ReloadHelpers
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
let_it_be
(
:namespace
)
{
create_default
(
:namespace
).
freeze
}
let_it_be
(
:namespace
)
{
create_default
(
:namespace
).
freeze
}
...
@@ -3022,72 +3021,31 @@ RSpec.describe Project, factory_default: :keep do
...
@@ -3022,72 +3021,31 @@ RSpec.describe Project, factory_default: :keep do
end
end
end
end
shared_context
'project with ancestors
'
do
describe
'#ancestors_upto
'
do
let_it_be
(
:parent
)
{
create
(
:group
)
}
let_it_be
(
:parent
)
{
create
(
:group
)
}
let_it_be
(
:child
)
{
create
(
:group
,
parent:
parent
)
}
let_it_be
(
:child
)
{
create
(
:group
,
parent:
parent
)
}
let_it_be
(
:child2
)
{
create
(
:group
,
parent:
child
)
}
let_it_be
(
:child2
)
{
create
(
:group
,
parent:
child
)
}
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
child2
)
}
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
child2
)
}
end
shared_examples
'#ancestors'
do
it
'returns all ancestors when no namespace is given'
do
before
do
expect
(
project
.
ancestors_upto
).
to
contain_exactly
(
child2
,
child
,
parent
)
reload_models
(
parent
,
child
,
child2
)
end
end
it
'
returns all ancestors
'
do
it
'
includes ancestors upto but excluding the given ancestor
'
do
expect
(
project
.
ancestors
).
to
contain_exactly
(
child2
,
child
,
parent
)
expect
(
project
.
ancestors
_upto
(
parent
)).
to
contain_exactly
(
child2
,
child
)
end
end
describe
'with hierarchy_order'
do
describe
'with hierarchy_order'
do
it
'returns ancestors ordered by descending hierarchy'
do
it
'returns ancestors ordered by descending hierarchy'
do
expect
(
project
.
ancestors
(
hierarchy_order: :desc
).
to_a
).
to
eq
([
parent
,
child
,
child2
])
expect
(
project
.
ancestors_upto
(
hierarchy_order: :desc
)).
to
eq
([
parent
,
child
,
child2
])
end
end
end
describe
'#ancestors'
do
include_context
'project with ancestors'
include_examples
'#ancestors'
end
describe
'#ancestors_upto'
do
include_context
'project with ancestors'
include_examples
'#ancestors'
it
'includes ancestors upto but excluding the given ancestor'
do
expect
(
project
.
ancestors_upto
(
parent
)).
to
contain_exactly
(
child2
,
child
)
end
end
describe
'with hierarchy_order'
do
it
'can be used with upto option'
do
it
'can be used with upto option'
do
expect
(
project
.
ancestors_upto
(
parent
,
hierarchy_order: :desc
)).
to
eq
([
child
,
child2
])
expect
(
project
.
ancestors_upto
(
parent
,
hierarchy_order: :desc
)).
to
eq
([
child
,
child2
])
end
end
end
end
end
end
describe
'#ancestors'
do
let_it_be
(
:parent
)
{
create
(
:group
)
}
let_it_be
(
:child
)
{
create
(
:group
,
parent:
parent
)
}
let_it_be
(
:child2
)
{
create
(
:group
,
parent:
child
)
}
let_it_be
(
:project
)
{
create
(
:project
,
namespace:
child2
)
}
before
do
reload_models
(
parent
,
child
,
child2
)
end
it
'returns all ancestors'
do
expect
(
project
.
ancestors
).
to
contain_exactly
(
child2
,
child
,
parent
)
end
describe
'with hierarchy_order'
do
it
'returns ancestors ordered by descending hierarchy'
do
expect
(
project
.
ancestors
(
hierarchy_order: :desc
).
to_a
).
to
eq
([
parent
,
child
,
child2
])
end
end
end
describe
'#root_ancestor'
do
describe
'#root_ancestor'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:project
)
{
create
(
:project
)
}
...
...
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