diff options
author | George Koltsov <koltsov.george@gmail.com> | 2019-08-21 10:13:45 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-08-21 10:13:45 +0000 |
commit | 8bcc47ac02e69eb4564238b454ca8286a4126765 (patch) | |
tree | c1cfec9a502c619193909e363250f8e9089eb0a7 /app/controllers/explore/projects_controller.rb | |
parent | 2c4fa09b21303e637c2cf2cabd47d1737c70f21d (diff) | |
download | gitlab-ce-8bcc47ac02e69eb4564238b454ca8286a4126765.tar.gz |
Add SortingPreference concern
Sorting preference functionality has been extracted
from `IssuableCollections` to a new `SortingPreference`
concern in order to reuse this functionality in projects
(and groups in the future).
Diffstat (limited to 'app/controllers/explore/projects_controller.rb')
-rw-r--r-- | app/controllers/explore/projects_controller.rb | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/app/controllers/explore/projects_controller.rb b/app/controllers/explore/projects_controller.rb index ef86d5f981a..271f2b4b57d 100644 --- a/app/controllers/explore/projects_controller.rb +++ b/app/controllers/explore/projects_controller.rb @@ -3,12 +3,13 @@ class Explore::ProjectsController < Explore::ApplicationController include ParamsBackwardCompatibility include RendersMemberAccess + include SortingHelper + include SortingPreference before_action :set_non_archived_param + before_action :set_sorting def index - params[:sort] ||= 'latest_activity_desc' - @sort = params[:sort] @projects = load_projects respond_to do |format| @@ -23,7 +24,6 @@ class Explore::ProjectsController < Explore::ApplicationController def trending params[:trending] = true - @sort = params[:sort] @projects = load_projects respond_to do |format| @@ -67,4 +67,17 @@ class Explore::ProjectsController < Explore::ApplicationController prepare_projects_for_rendering(projects) end # rubocop: enable CodeReuse/ActiveRecord + + def set_sorting + params[:sort] = set_sort_order + @sort = params[:sort] + end + + def default_sort_order + sort_value_latest_activity + end + + def sorting_field + Project::SORTING_PREFERENCE_FIELD + end end |