Paginate banned competitors page
fixes: https://github.com/thewca/worldcubeassociation.org/issues/11710
Copy pasta from incident log component
You're manually paginating the frontend, but is this still making sure you're pulling all the data from the backend as required?
@gregorbg It hasn’t been fully tested yet, which is why it’s still in draft.
Will any backend changes be required for this?
@gregorbg It hasn’t been fully tested yet, which is why it’s still in draft.
I know, that's why I submitted a simple comment instead of a strict "Request Changes" review :P
Will any backend changes be required for this?
I don't know. It depends on what you're trying to achieve. Right now, in the current draft state, the pagination will be purely front-end. That is, the front-end will paginate its data in a nice table, but maybe there is even more data in the backend's database which is completely ignored.
@pranav-027 Thanks for taking this up. Backend changes won't be needed. You just need to pass the page number as the argument with normal roles fetching API. For example, let's say you are using '/user_roles?(...)' for fetching list of roles. When you use pagination, you should use '/user_roles?(...)&page=n' (where n is the page number). The backend for the same is already handled. You can try out by opening some URLs (like /api/v0/user_roles?page=3) in your browser.
Currently looking like this and i found comment by daniel as well in the user_roles_controller.rb
def index
roles = pre_filtered_user_roles
# Filter & Sort roles.
roles = UserRole.filter_roles(roles, current_user, params)
roles = UserRole.sort_roles(roles, params[:sort])
# Paginating the list by sending only first 100 elements unless mentioned in the API.
paginate json: roles
end