summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEzekiel Kigbo <ekigbo@gitlab.com>2019-04-12 11:47:42 +0200
committerEzekiel Kigbo <ekigbo@gitlab.com>2019-05-06 16:41:46 +0100
commitc1f5205d9123d7f497d56235b4330145ef80a652 (patch)
tree67a01b4dc5e66e6afc93f5b7f343f63d8799d7bd
parent6daec21a161821816b1eda03b52369d61685fe48 (diff)
downloadgitlab-ce-c1f5205d9123d7f497d56235b4330145ef80a652.tar.gz
Added sorted_by_stars_asc scope to projects model
-rw-r--r--app/models/project.rb3
1 files changed, 3 insertions, 0 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 228ab9e9618..da5f2c2e96e 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -358,6 +358,7 @@ class Project < ApplicationRecord
# last_activity_at is throttled every minute, but last_repository_updated_at is updated with every push
scope :sorted_by_activity, -> { reorder("GREATEST(COALESCE(last_activity_at, '1970-01-01'), COALESCE(last_repository_updated_at, '1970-01-01')) DESC") }
scope :sorted_by_stars, -> { reorder(star_count: :desc) }
+ scope :sorted_by_stars_asc, -> { reorder(star_count: :asc) }
scope :in_namespace, ->(namespace_ids) { where(namespace_id: namespace_ids) }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
@@ -545,6 +546,8 @@ class Project < ApplicationRecord
reorder(last_activity_at: :asc)
when 'stars_desc'
sorted_by_stars
+ when 'stars_asc'
+ sorted_by_stars_asc
else
order_by(method)
end