Commit c1f5205d authored by Ezekiel Kigbo's avatar Ezekiel Kigbo

Added sorted_by_stars_asc scope to projects model

parent 6daec21a
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment