summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorJacopo <beschi.jacopo@gmail.com>2017-03-03 11:35:04 +0100
committerJacopo <beschi.jacopo@gmail.com>2017-04-06 07:11:37 +0200
commitb996a82ff44e3bcad5e5fb70cabbfa808d06cf62 (patch)
treed5a39a4a0e1b8d26eb9d6c47d817b2a0ff6ba6ce /app/models
parent280531a762e4922761b79403934c549203e5b45f (diff)
downloadgitlab-ce-b996a82ff44e3bcad5e5fb70cabbfa808d06cf62.tar.gz
ProjectsFinder should handle more options
Extended ProjectFinder in order to handle the following options: - current_user - which user use - project_ids_relation: int[] - project ids to use - params: - trending: boolean - non_public: boolean - starred: boolean - sort: string - visibility_level: int - tags: string[] - personal: boolean - search: string - non_archived: boolean GroupProjectsFinder now inherits from ProjectsFinder. Changed the code in order to use the new available options.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 12fd0668ff8..1f95d00baf8 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -349,10 +349,15 @@ class Project < ActiveRecord::Base
end
def sort(method)
- if method == 'storage_size_desc'
+ case method.to_s
+ when 'storage_size_desc'
# storage_size is a joined column so we need to
# pass a string to avoid AR adding the table name
reorder('project_statistics.storage_size DESC, projects.id DESC')
+ when 'latest_activity_desc'
+ reorder(last_activity_at: :desc)
+ when 'latest_activity_asc'
+ reorder(last_activity_at: :asc)
else
order_by(method)
end