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
6bdf92f0
Commit
6bdf92f0
authored
Dec 12, 2019
by
Dylan Griffith
Committed by
Mark Chao
Dec 16, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove an N+1 call rendering projects search results
parent
26ccbc3e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
4 deletions
+18
-4
app/helpers/users_helper.rb
app/helpers/users_helper.rb
+8
-0
app/views/shared/projects/_list.html.haml
app/views/shared/projects/_list.html.haml
+1
-0
changelogs/unreleased/34457-remove-n-plus-1-search.yml
changelogs/unreleased/34457-remove-n-plus-1-search.yml
+5
-0
ee/spec/features/search/elastic/global_search_spec.rb
ee/spec/features/search/elastic/global_search_spec.rb
+4
-4
No files found.
app/helpers/users_helper.rb
View file @
6bdf92f0
...
...
@@ -44,6 +44,14 @@ module UsersHelper
current_user_menu_items
.
include?
(
item
)
end
# Used to preload when you are rendering many projects and checking access
#
# rubocop: disable CodeReuse/ActiveRecord: `projects` can be array which also responds to pluck
def
load_max_project_member_accesses
(
projects
)
current_user
&
.
max_member_access_for_project_ids
(
projects
.
pluck
(
:id
))
end
# rubocop: enable CodeReuse/ActiveRecord
def
max_project_member_access
(
project
)
current_user
&
.
max_member_access_for_project
(
project
.
id
)
||
Gitlab
::
Access
::
NO_ACCESS
end
...
...
app/views/shared/projects/_list.html.haml
View file @
6bdf92f0
...
...
@@ -35,6 +35,7 @@
.js-projects-list-holder
{
data:
{
qa_selector:
'projects_list'
}
}
-
if
any_projects?
(
projects
)
-
load_pipeline_status
(
projects
)
if
pipeline_status
-
load_max_project_member_accesses
(
projects
)
# Prime cache used in shared/projects/project view rendered below
%ul
.projects-list
{
class:
css_classes
}
-
projects
.
each_with_index
do
|
project
,
i
|
-
css_class
=
(
i
>=
projects_limit
)
||
project
.
pending_delete?
?
'hide'
:
nil
...
...
changelogs/unreleased/34457-remove-n-plus-1-search.yml
0 → 100644
View file @
6bdf92f0
---
title
:
Remove an N+1 call rendering projects search results
merge_request
:
21626
author
:
type
:
performance
ee/spec/features/search/elastic/global_search_spec.rb
View file @
6bdf92f0
...
...
@@ -43,10 +43,10 @@ describe 'Global elastic search', :elastic do
let
(
:object
)
{
:project
}
let
(
:creation_args
)
{
{
namespace:
user
.
namespace
}
}
let
(
:path
)
{
search_path
(
search:
'project*'
,
scope:
'projects'
)
}
# Each Project requires
5
extra queries: one for each "count" (forks,
# open MRs, open Issues
) and twice for access level. This should be fixed
#
per
https://gitlab.com/gitlab-org/gitlab/issues/34457
let
(
:query_count_multiplier
)
{
5
}
# Each Project requires
4
extra queries: one for each "count" (forks,
# open MRs, open Issues
and access levels). This should be fixed per
# https://gitlab.com/gitlab-org/gitlab/issues/34457
let
(
:query_count_multiplier
)
{
4
}
it_behaves_like
'an efficient database result'
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