Put current user first, closes #2063

This commit is contained in:
Toks
2015-04-23 09:43:19 -04:00
parent 6ff02c653d
commit c56d16d336
2 changed files with 5 additions and 0 deletions

View File

@@ -301,6 +301,7 @@
url: "/users.json", url: "/users.json",
data: { data: {
"search[order]": "post_upload_count", "search[order]": "post_upload_count",
"search[current_user_first]": "true",
"search[name_matches]": term + "*", "search[name_matches]": term + "*",
"limit": 10, "limit": 10,
}, },

View File

@@ -712,6 +712,10 @@ class User < ActiveRecord::Base
q = q.where("id in (?)", params[:id].split(",").map(&:to_i)) q = q.where("id in (?)", params[:id].split(",").map(&:to_i))
end end
if params[:current_user_first] == "true" && !CurrentUser.is_anonymous?
q = q.order("id = #{CurrentUser.user.id.to_i} desc")
end
case params[:order] case params[:order]
when "name" when "name"
q = q.order("name") q = q.order("name")