worldcubeassociation.org icon indicating copy to clipboard operation
worldcubeassociation.org copied to clipboard

Paginate banned competitors page

Open pranav-027 opened this issue 7 months ago • 5 comments

fixes: https://github.com/thewca/worldcubeassociation.org/issues/11710

Copy pasta from incident log component

pranav-027 avatar Jun 03 '25 11:06 pranav-027

You're manually paginating the frontend, but is this still making sure you're pulling all the data from the backend as required?

gregorbg avatar Jun 03 '25 14:06 gregorbg

@gregorbg It hasn’t been fully tested yet, which is why it’s still in draft.

Will any backend changes be required for this?

pranav-027 avatar Jun 03 '25 14:06 pranav-027

@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.

gregorbg avatar Jun 03 '25 14:06 gregorbg

@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.

danieljames-dj avatar Jun 03 '25 15:06 danieljames-dj

screen-capture (4).webm

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

pranav-027 avatar Jun 03 '25 15:06 pranav-027