diff --git a/app/controllers/v1/users_controller.rb b/app/controllers/v1/users_controller.rb index 5fdc1d08a35c986ab855241a6c83a5eef6e2bb2a..de41f351399871c2eecf7d952df8d6859de3c7ac 100644 --- a/app/controllers/v1/users_controller.rb +++ b/app/controllers/v1/users_controller.rb @@ -178,9 +178,12 @@ class V1::UsersController < ApplicationController render status: :ok, json: response end + # GET /v1/top_users def show_top_users - # 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 + ids = User.joins(:roles_users).where(roles_users: {role_id: 3}).pluck(:user_id) + users = User.where.not(id: ids).order("level DESC").limit(5) + render json: users end