This instance will be upgraded to Heptapod 0.26.0rc1 on 2021-10-26 at 14:30 UTC+2 (a few minutes of down time)

Commit 14c268cf authored by Ezekiel Kigbo's avatar Ezekiel Kigbo
Browse files

Added sorted_by_stars_asc scope to projects model

parent fcc0c25f238a
......@@ -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 @@ def sort_by_attribute(method)
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