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
Léo-Paul Géneau
gitlab-ce
Commits
901e70fb
Commit
901e70fb
authored
Mar 15, 2017
by
Bob Van Landuyt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Eager load route & namespace in `Explore::ProjectsController`
parent
9cca8c00
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
app/controllers/explore/projects_controller.rb
app/controllers/explore/projects_controller.rb
+11
-3
No files found.
app/controllers/explore/projects_controller.rb
View file @
901e70fb
...
...
@@ -2,7 +2,7 @@ class Explore::ProjectsController < Explore::ApplicationController
include
FilterProjects
def
index
@projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
@projects
=
load_projects
@tags
=
@projects
.
tags_on
(
:tags
)
@projects
=
@projects
.
tagged_with
(
params
[
:tag
])
if
params
[
:tag
].
present?
@projects
=
@projects
.
where
(
visibility_level:
params
[
:visibility_level
])
if
params
[
:visibility_level
].
present?
...
...
@@ -21,7 +21,8 @@ class Explore::ProjectsController < Explore::ApplicationController
end
def
trending
@projects
=
filter_projects
(
Project
.
trending
)
@projects
=
load_projects
(
Project
.
trending
)
@projects
=
filter_projects
(
@projects
)
@projects
=
@projects
.
sort
(
@sort
=
params
[
:sort
])
@projects
=
@projects
.
page
(
params
[
:page
])
...
...
@@ -36,7 +37,7 @@ class Explore::ProjectsController < Explore::ApplicationController
end
def
starred
@projects
=
ProjectsFinder
.
new
.
execute
(
current_user
)
@projects
=
load_projects
@projects
=
filter_projects
(
@projects
)
@projects
=
@projects
.
reorder
(
'star_count DESC'
)
@projects
=
@projects
.
page
(
params
[
:page
])
...
...
@@ -50,4 +51,11 @@ class Explore::ProjectsController < Explore::ApplicationController
end
end
end
protected
def
load_projects
(
base_scope
=
nil
)
base_scope
||=
ProjectsFinder
.
new
.
execute
(
current_user
)
base_scope
.
includes
(
:route
,
namespace: :route
)
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