mirror of
https://github.com/discourse/discourse.git
synced 2025-05-23 18:41:07 +08:00
Add pagination to /admin/users/list API
Prior to this, only the first 100 active/new/etc. users were available via the `/admin/users/list` API. This change adds support for a `page=#` querystring parameter so that *all* of the users can be retrieved. Requests for pages past the last user result in an empty-list response; requests for negative pages (or zero) just return the first page. Added tests to cover pagination.
This commit is contained in:
@ -25,7 +25,11 @@ class AdminUserIndexQuery
|
||||
}
|
||||
|
||||
def find_users(limit=100)
|
||||
find_users_query.limit(limit)
|
||||
page = params[:page].to_i - 1
|
||||
if page < 0
|
||||
page = 0
|
||||
end
|
||||
find_users_query.limit(limit).offset(page * limit)
|
||||
end
|
||||
|
||||
def count_users
|
||||
|
Reference in New Issue
Block a user