Skip to content
Snippets Groups Projects
Commit 3268d4c7 authored by Richard Fernando Heise Ferreira's avatar Richard Fernando Heise Ferreira
Browse files

Merge branch 'issue-41/update-show-top-users' into 'develop'

ISSUE #41: UPDATE top_users route

See merge request rfhf19/cleanning-portalmec!40
parents 396aff79 d129a403
No related branches found
No related tags found
1 merge request!40ISSUE #41: UPDATE top_users route
Pipeline #34020 failed
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment