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
bf3bd577
Commit
bf3bd577
authored
Jan 28, 2019
by
Camil Staps
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rewrite StarredProjectsFinder to use ProjectsFinder
parent
a052f681
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
30 deletions
+5
-30
app/controllers/users_controller.rb
app/controllers/users_controller.rb
+1
-1
app/finders/starred_projects_finder.rb
app/finders/starred_projects_finder.rb
+4
-29
No files found.
app/controllers/users_controller.rb
View file @
bf3bd577
...
@@ -134,7 +134,7 @@ class UsersController < ApplicationController
...
@@ -134,7 +134,7 @@ class UsersController < ApplicationController
end
end
def
starred_projects
def
starred_projects
StarredProjectsFinder
.
new
(
user
).
execute
(
current_user
)
StarredProjectsFinder
.
new
(
user
,
current_user:
current_user
).
execute
end
end
def
contributions_calendar
def
contributions_calendar
...
...
app/finders/starred_projects_finder.rb
View file @
bf3bd577
# frozen_string_literal: true
# frozen_string_literal: true
class
StarredProjectsFinder
<
UnionFinder
class
StarredProjectsFinder
<
ProjectsFinder
def
initialize
(
user
)
def
initialize
(
user
,
params:
{},
current_user:
nil
)
@user
=
user
project_ids
=
user
.
starred_projects
.
includes
(
:creator
).
select
(
:id
)
end
super
(
params:
params
,
current_user:
current_user
,
project_ids_relation:
project_ids
)
# Finds the projects "@user" starred, limited to either public projects or
# projects visible to the given user.
#
# current_user - When given the list of the projects is limited to those only
# visible by this user.
#
# Returns an ActiveRecord::Relation.
# rubocop: disable CodeReuse/ActiveRecord
def
execute
(
current_user
=
nil
)
segments
=
all_projects
(
current_user
)
find_union
(
segments
,
Project
).
includes
(
:namespace
).
order_id_desc
end
# rubocop: enable CodeReuse/ActiveRecord
private
def
all_projects
(
current_user
)
projects
=
[]
projects
<<
@user
.
starred_projects
.
visible_to_user
(
current_user
)
if
current_user
projects
<<
@user
.
starred_projects
.
public_to_user
(
current_user
)
projects
end
end
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