Skip to content

Send absolute row index in request when "last" pagination button is clicked - #7211

Merged
wetneb merged 2 commits into
OpenRefine:masterfrom
SoryRawyer:issue-7207-fix-last-pagination
Mar 20, 2025
Merged

wetneb merged 2 commits into
OpenRefine:masterfrom
SoryRawyer:issue-7207-fix-last-pagination

Conversation

@SoryRawyer

Copy link
Copy Markdown
Member

Fixes #7207

Changes proposed in this pull request:

  • This change addresses how the "last" pagination navigation button sends the ending point. The current behavior is that it sends the index of the last row relative to a faceted search, and this change is to send the index of the absolute last row in the project.
  • This also includes a change to omit the nextPageStart variable if there are fewer than limit elements in the response. This will cause the next and last pagination buttons to be marked as inactive, as there are no more elements to paginate through.

This change addresses how the "last" pagination navigation button sends
the ending point. The current behavior is that it sends the index of the
last row relative to a faceted search, and this change is to send the
index of the absolute last row in the project.
This also includes a change to omit the `nextPageStart` variable if
there are fewer than `limit` elements in the response. This will cause
the `next` and `last` pagination buttons to be marked as inactive, as
there are no more elements to paginate through.
@github-actions github-actions Bot added Type: Bug Issues related to software defects or unexpected behavior, which require resolution. Status: Pending Review Indicates that the issue or pull request is awaiting review by project maintainers or collaborators labels Mar 18, 2025

@wetneb wetneb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for tackling this!

I agree that clicking Last should use the total number of rows in the project, regardless of the filtering. Unfortunately, rowModel.total isn't quite that: in records mode, this will be the total number of records in the project. And when paginating through records, we still use the row ids to specify page boundaries, so we'd need to still use the total number of rows in the project in this case.

I can't see anywhere else where rowModel.totalRows is being used, so I think it would make sense to instead fix the backend to make sure this still contains the total number of rows in the project (regardless of the rows/record mode and of filtering options).

Also, it would be nice to have some automated tests covering your changes. Java unit tests are probably sufficient and faster.

@SoryRawyer

SoryRawyer commented Mar 20, 2025 •

Copy link
Copy Markdown
Member Author

Ah, I wasn't sure how this would affect records mode, thank you for clarifying that! I'm trying to add a test to make sure faceted search paginates correctly, but I'm having a hard time actually adding a facet within the test. I tried looking at the network tab in my browser tools to get the engine JSON that I could pass to the mocked getParameter("engine") call, but I don't think that's being applied properly during the test.
I was thinking it could be possible if I copy some of the code from TextSearchFacetTests, but do you think there's a more convenient way to add a facet to a project in this case?

Edit: I got around this by registering the GREL parser in the test setup, which seems to be a common pattern in other tests. Please let me know if that's not a reasonable addition here.

This commit changes the behavior of GetRowsCommand to return the total
number of rows in a project as the `totalRows` field, rather than
returning the filtered row count.
This commit also adds two tests to GetRowsCommandTest, to test that
pagination still works as expected when facets are applied.

@wetneb wetneb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@wetneb
wetneb merged commit d6caf4c into OpenRefine:master Mar 20, 2025
wetneb pushed a commit that referenced this pull request Mar 26, 2025
…licked (#7211)

* fixes #7207

This change addresses how the "last" pagination navigation button sends
the ending point. The current behavior is that it sends the index of the
last row relative to a faceted search, and this change is to send the
index of the absolute last row in the project.
This also includes a change to omit the `nextPageStart` variable if
there are fewer than `limit` elements in the response. This will cause
the `next` and `last` pagination buttons to be marked as inactive, as
there are no more elements to paginate through.

* set totalRows to project row length and add tests

This commit changes the behavior of GetRowsCommand to return the total
number of rows in a project as the `totalRows` field, rather than
returning the filtered row count.
This commit also adds two tests to GetRowsCommandTest, to test that
pagination still works as expected when facets are applied.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Status: Pending Review Indicates that the issue or pull request is awaiting review by project maintainers or collaborators Type: Bug Issues related to software defects or unexpected behavior, which require resolution.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incorrect behaviour of row view navigation buttons in facet-filtered view

2 participants