diff --git a/app/controllers/v1/users_controller.rb b/app/controllers/v1/users_controller.rb index 5fdc1d08a35c986ab855241a6c83a5eef6e2bb2a..dcc94b826080d61a9d3ce02dc82a78765062350a 100644 --- a/app/controllers/v1/users_controller.rb +++ b/app/controllers/v1/users_controller.rb @@ -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