/forum_topics: don't list stickies first in json/atom responses.
This commit is contained in:
@@ -68,9 +68,12 @@ class ForumTopic < ActiveRecord::Base
|
||||
where("min_level <= ?", CurrentUser.level)
|
||||
end
|
||||
|
||||
def sticky_first
|
||||
order(is_sticky: :desc, updated_at: :desc)
|
||||
end
|
||||
|
||||
def search(params)
|
||||
q = permitted
|
||||
return q if params.blank?
|
||||
|
||||
if params[:id].present?
|
||||
q = q.where(id: params[:id].split(",").map(&:to_i))
|
||||
@@ -92,6 +95,13 @@ class ForumTopic < ActiveRecord::Base
|
||||
q = q.where("title = ?", params[:title])
|
||||
end
|
||||
|
||||
case params[:order]
|
||||
when "sticky"
|
||||
q = q.sticky_first
|
||||
else
|
||||
q = q.order(updated_at: :desc)
|
||||
end
|
||||
|
||||
q
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user