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
624e246b
Commit
624e246b
authored
Aug 02, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve GeoNode#project_ids to save one query
parent
5a699322
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
6 deletions
+6
-6
app/models/geo_node.rb
app/models/geo_node.rb
+3
-3
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+3
-3
No files found.
app/models/geo_node.rb
View file @
624e246b
...
...
@@ -109,9 +109,9 @@ class GeoNode < ActiveRecord::Base
end
def
project_ids
return
unless
namespaces
.
any?
namespaces
.
flat_map
{
|
namespace
|
namespace
.
all_projects
.
pluck
(
:id
)
}.
uniq
namespaces
.
flat_map
{
|
namespace
|
namespace
.
all_projects
.
select
(
:id
).
pluck
(
:id
)
}
.
uniq
.
presence
end
private
...
...
spec/models/geo_node_spec.rb
View file @
624e246b
...
...
@@ -318,14 +318,14 @@ describe GeoNode, type: :model do
end
describe
'#project_ids'
do
context
'without
group
restriction'
do
context
'without
namespace
restriction'
do
it
'returns nil'
do
expect
(
node
.
project_ids
).
to
be_nil
end
end
context
'with
group
restrictions'
do
it
'returns an array with unique project ids that belong to the
group
s'
do
context
'with
namespace
restrictions'
do
it
'returns an array with unique project ids that belong to the
namespace
s'
do
group_1
=
create
(
:group
)
group_2
=
create
(
:group
)
nested_group_1
=
create
(
:group
,
parent:
group_1
)
...
...
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