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
0
Merge Requests
0
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
Jérome Perrin
gitlab-ce
Commits
871bed7a
Commit
871bed7a
authored
Mar 16, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Enumerable#index_by where possible
parent
0928d3cd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
5 additions
and
20 deletions
+5
-20
app/services/merge_requests/get_urls_service.rb
app/services/merge_requests/get_urls_service.rb
+1
-4
app/services/users/refresh_authorized_projects_service.rb
app/services/users/refresh_authorized_projects_service.rb
+1
-3
lib/banzai/filter/abstract_reference_filter.rb
lib/banzai/filter/abstract_reference_filter.rb
+1
-6
lib/banzai/filter/user_reference_filter.rb
lib/banzai/filter/user_reference_filter.rb
+1
-4
lib/banzai/reference_parser/base_parser.rb
lib/banzai/reference_parser/base_parser.rb
+1
-3
No files found.
app/services/merge_requests/get_urls_service.rb
View file @
871bed7a
...
@@ -23,10 +23,7 @@ module MergeRequests
...
@@ -23,10 +23,7 @@ module MergeRequests
def
opened_merge_requests_from_source_branches
(
branches
)
def
opened_merge_requests_from_source_branches
(
branches
)
merge_requests
=
MergeRequest
.
from_project
(
project
).
opened
.
from_source_branches
(
branches
)
merge_requests
=
MergeRequest
.
from_project
(
project
).
opened
.
from_source_branches
(
branches
)
merge_requests
.
inject
({})
do
|
hash
,
mr
|
merge_requests
.
index_by
(
&
:source_branch
)
hash
[
mr
.
source_branch
]
=
mr
hash
end
end
end
def
get_branches
(
changes
)
def
get_branches
(
changes
)
...
...
app/services/users/refresh_authorized_projects_service.rb
View file @
871bed7a
...
@@ -93,9 +93,7 @@ module Users
...
@@ -93,9 +93,7 @@ module Users
end
end
def
current_authorizations_per_project
def
current_authorizations_per_project
current_authorizations
.
each_with_object
({})
do
|
row
,
hash
|
current_authorizations
.
index_by
(
&
:project_id
)
hash
[
row
.
project_id
]
=
row
end
end
end
def
current_authorizations
def
current_authorizations
...
...
lib/banzai/filter/abstract_reference_filter.rb
View file @
871bed7a
...
@@ -239,18 +239,13 @@ module Banzai
...
@@ -239,18 +239,13 @@ module Banzai
# path.
# path.
def
projects_per_reference
def
projects_per_reference
@projects_per_reference
||=
begin
@projects_per_reference
||=
begin
hash
=
{}
refs
=
Set
.
new
refs
=
Set
.
new
references_per_project
.
each
do
|
project_ref
,
_
|
references_per_project
.
each
do
|
project_ref
,
_
|
refs
<<
project_ref
refs
<<
project_ref
end
end
find_projects_for_paths
(
refs
.
to_a
).
each
do
|
project
|
find_projects_for_paths
(
refs
.
to_a
).
index_by
(
&
:full_path
)
hash
[
project
.
path_with_namespace
]
=
project
end
hash
end
end
end
end
...
...
lib/banzai/filter/user_reference_filter.rb
View file @
871bed7a
...
@@ -74,10 +74,7 @@ module Banzai
...
@@ -74,10 +74,7 @@ module Banzai
# The keys of this Hash are the namespace paths, the values the
# The keys of this Hash are the namespace paths, the values the
# corresponding Namespace objects.
# corresponding Namespace objects.
def
namespaces
def
namespaces
@namespaces
||=
@namespaces
||=
Namespace
.
where_full_path_in
(
usernames
).
index_by
(
&
:full_path
)
Namespace
.
where_full_path_in
(
usernames
).
each_with_object
({})
do
|
row
,
hash
|
hash
[
row
.
full_path
]
=
row
end
end
end
# Returns all usernames referenced in the current document.
# Returns all usernames referenced in the current document.
...
...
lib/banzai/reference_parser/base_parser.rb
View file @
871bed7a
...
@@ -134,9 +134,7 @@ module Banzai
...
@@ -134,9 +134,7 @@ module Banzai
ids
=
unique_attribute_values
(
nodes
,
attribute
)
ids
=
unique_attribute_values
(
nodes
,
attribute
)
rows
=
collection_objects_for_ids
(
collection
,
ids
)
rows
=
collection_objects_for_ids
(
collection
,
ids
)
rows
.
each_with_object
({})
do
|
row
,
hash
|
rows
.
index_by
(
&
:id
)
hash
[
row
.
id
]
=
row
end
end
end
# Returns an Array containing all unique values of an attribute of the
# Returns an Array containing all unique values of an attribute of the
...
...
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