mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-23 15:48:43 -05:00
FEATURE: add parameter that allows you to filter directory items on user
adding ?username= will filter directory_items.json by the username
This commit is contained in:
parent
92724dcee1
commit
736cbf3d2d
1 changed files with 9 additions and 0 deletions
|
@ -35,6 +35,15 @@ class DirectoryItemsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
if params[:username]
|
||||
user_id = User.where(username_lower: params[:username].to_s.downcase).pluck(:id).first
|
||||
if user_id
|
||||
result = result.where(user_id: user_id)
|
||||
else
|
||||
result = result.where('false')
|
||||
end
|
||||
end
|
||||
|
||||
result = result.order('users.username')
|
||||
result_count = result.dup.count
|
||||
result = result.limit(PAGE_SIZE).offset(PAGE_SIZE * page).to_a
|
||||
|
|
Loading…
Reference in a new issue