Skip to content
Snippets Groups Projects
Commit c5c0bfba authored by tmn21's avatar tmn21 :rocket:
Browse files

ISSUE #41: UPDATE top_users route

parent 396aff79
No related branches found
No related tags found
No related merge requests found
Pipeline #34009 failed
......@@ -178,9 +178,15 @@ class V1::UsersController < ApplicationController
render status: :ok, json: response
end
# GET /v1/top_users
def show_top_users
# users = User.all.order("level DESC").limit(5)
# select id, level from users order by level desc limit 5;
users = paginate User.all.order("level DESC").limit(6)
# select users who are not admin and order by level, limit to 5 users
# TO DO: the query isn't excluding admin users
ids = User.joins(:roles_users).where.not(roles_users: {role_id: 3})
users = User.where(id: ids).order("level DESC").limit(5)
render json: users
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment