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:
authorCamil Staps <info@camilstaps.nl>2019-01-28 15:19:53 +0300
committerCamil Staps <info@camilstaps.nl>2019-08-07 21:49:14 +0300
commit6baff6504b234e209a5e1d78349dbd2589d5d7e8 (patch)
tree809269461586e00974cb8c309c77aca77b058e49 /app/finders
parent91f574b820e03b4abb97a8351e420d1ef24e8505 (diff)
Change sorting options for starrers: name (asc/desc), most/least recent star
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/users_finder.rb5
-rw-r--r--app/finders/users_star_projects_finder.rb31
2 files changed, 31 insertions, 5 deletions
diff --git a/app/finders/users_finder.rb b/app/finders/users_finder.rb
index 2f3fc24b243..81ae50c0bd1 100644
--- a/app/finders/users_finder.rb
+++ b/app/finders/users_finder.rb
@@ -37,7 +37,6 @@ class UsersFinder
users = by_2fa(users)
users = by_created_at(users)
users = by_custom_attributes(users)
- users = by_has_starred(users)
users
end
@@ -95,8 +94,4 @@ class UsersFinder
users
end
end
-
- def by_has_starred(items)
- params[:has_starred].present? ? items.has_starred(params[:has_starred]) : items
- 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..66b83fa8f8e
--- /dev/null
+++ b/app/finders/users_star_projects_finder.rb
@@ -0,0 +1,31 @@
+# frozen_string_literal: true
+
+class UsersStarProjectsFinder
+ include CustomAttributesFilter
+
+ attr_accessor :params
+
+ def initialize(params = {})
+ @params = params
+ end
+
+ def execute
+ stars = UsersStarProject.all.order_id_desc
+ stars = by_search(stars)
+ stars = by_project(stars)
+
+ stars
+ end
+
+ private
+
+ def by_search(items)
+ return items unless params[:search].present?
+
+ items.search(params[:search])
+ end
+
+ def by_project(items)
+ params[:project].present? ? items.by_project(params[:project]) : items
+ end
+end