summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/starred_projects_finder.rb11
-rw-r--r--app/finders/users_star_projects_finder.rb36
2 files changed, 47 insertions, 0 deletions
diff --git a/app/finders/starred_projects_finder.rb b/app/finders/starred_projects_finder.rb
new file mode 100644
index 00000000000..fcb469d1d17
--- /dev/null
+++ b/app/finders/starred_projects_finder.rb
@@ -0,0 +1,11 @@
+# frozen_string_literal: true
+
+class StarredProjectsFinder < ProjectsFinder
+ def initialize(user, params: {}, current_user: nil)
+ super(
+ params: params,
+ current_user: current_user,
+ project_ids_relation: user.starred_projects.select(:id)
+ )
+ end
+end
diff --git a/app/finders/users_star_projects_finder.rb b/app/finders/users_star_projects_finder.rb
new file mode 100644
index 00000000000..49c4e087b4b
--- /dev/null
+++ b/app/finders/users_star_projects_finder.rb
@@ -0,0 +1,36 @@
+# frozen_string_literal: true
+
+class UsersStarProjectsFinder
+ include CustomAttributesFilter
+
+ attr_accessor :params
+
+ def initialize(project, params = {}, current_user: nil)
+ @params = params
+ @project = project
+ @current_user = current_user
+ end
+
+ def execute
+ stars = UsersStarProject.all
+ stars = by_project(stars)
+ stars = by_search(stars)
+ stars = filter_visible_profiles(stars)
+
+ stars
+ end
+
+ private
+
+ def by_search(items)
+ params[:search].present? ? items.search(params[:search]) : items
+ end
+
+ def by_project(items)
+ items.by_project(@project)
+ end
+
+ def filter_visible_profiles(items)
+ items.with_visible_profile(@current_user)
+ end
+end