diff options
author | 🙈 jacopo beschi 🙉 <intrip@gmail.com> | 2018-09-21 17:06:55 +0000 |
---|---|---|
committer | Douglas Barbosa Alexandre <dbalexandre@gmail.com> | 2018-09-21 17:06:55 +0000 |
commit | c49c596d17f8d8b62e29f2fd1344ce08cb0a0b93 (patch) | |
tree | 3656bb26d05d473afd779511a2646f398e4f3123 /app/models | |
parent | 8f191590447d8e8aa375f1c1104540db5473ce51 (diff) | |
download | gitlab-ce-c49c596d17f8d8b62e29f2fd1344ce08cb0a0b93.tar.gz |
Allows to sort projects by most stars
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/project.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb index 9e4c7f7a2d0..3e14064a556 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -331,7 +331,7 @@ class Project < ActiveRecord::Base # 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('projects.star_count DESC') } + scope :sorted_by_stars, -> { reorder(star_count: :desc) } scope :in_namespace, ->(namespace_ids) { where(namespace_id: namespace_ids) } scope :personal, ->(user) { where(namespace_id: user.namespace_id) } @@ -481,6 +481,8 @@ class Project < ActiveRecord::Base reorder(last_activity_at: :desc) when 'latest_activity_asc' reorder(last_activity_at: :asc) + when 'stars_desc' + sorted_by_stars else order_by(method) end |