Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/users_controller.rb2
-rw-r--r--app/finders/starred_projects_finder.rb33
2 files changed, 5 insertions, 30 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 36687e3606e..bc1587e6be0 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -134,7 +134,7 @@ class UsersController < ApplicationController
end
def starred_projects
- StarredProjectsFinder.new(user).execute(current_user)
+ StarredProjectsFinder.new(user, current_user: current_user).execute
end
def contributions_calendar
diff --git a/app/finders/starred_projects_finder.rb b/app/finders/starred_projects_finder.rb
index e5eeb19a8f3..5d0c6820a26 100644
--- a/app/finders/starred_projects_finder.rb
+++ b/app/finders/starred_projects_finder.rb
@@ -1,33 +1,8 @@
# frozen_string_literal: true
-class StarredProjectsFinder < UnionFinder
- def initialize(user)
- @user = user
- end
-
- # 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
+class StarredProjectsFinder < ProjectsFinder
+ def initialize(user, params: {}, current_user: nil)
+ project_ids = user.starred_projects.includes(:creator).select(:id)
+ super(params: params, current_user: current_user, project_ids_relation: project_ids)
end
end