Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Paurikova2
Copy link
Collaborator

@Paurikova2 Paurikova2 commented Mar 24, 2025

Phases MP MM MB MR JM Total
ETA 1 0 0 0 0 0
Developing 1 0 0 0 0 0
Review 0 0 0 0 0 0
Total - - - - - 0
ETA est. 0
ETA cust. - - - - - 0

Problem description

There are no search results for some handles.
image

Problems

There is an issue with the pageable in the findAll endpoint. When we search for all results for the handle, the pageable is set to 20 in some cases. As a result, an exception occurs when trying to paginate the results, because the pageable is larger than the size of the result.

Solution

Calculate the pageable based on the size of the result.

Summary by CodeRabbit

  • Bug Fixes
    • Improved pagination behavior to ensure that navigating beyond the available content no longer results in errors or empty displays.

@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2025

Walkthrough

The changes update the pagination logic in the findAll method of the handle repository. The new logic checks if the offset from the Pageable exceeds the available number of handles. If it does, the code computes the last valid page number based on the total handle count and the page size, then creates a new PageRequest accordingly. This adjustment prevents errors or empty results when a client requests an out-of-bound page.

Changes

File(s) Change Summary
.../dspace/app/rest/repository/HandleRestRepository.java Updated pagination logic in the findAll method to adjust the PageRequest when the offset exceeds the total handle count.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Repository as HandleRestRepository
    participant Service as handleClarinService

    Client->>Repository: Call findAll(Pageable)
    Repository->>Service: Retrieve list of handles
    Service-->>Repository: Return total handles list
    alt Offset > total handles
        Repository->>Repository: Calculate last valid page & create new PageRequest
    end
    Repository->>Client: Return paginated results
Loading

Poem

I'm a joyful rabbit with code to share,
Hopping through lines with precision and care.
Adjusting pages when offsets stray,
My little tweaks make errors go away.
With each new line, my heart does cheer,
A bunny's code always brings delight near!


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ec96cb4 and db8be48.

📒 Files selected for processing (1)
  • dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/HandleRestRepository.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: dspace-dependencies / docker-build (linux/amd64, ubuntu-latest, true)
  • GitHub Check: Run Integration Tests
  • GitHub Check: Run Unit Tests
🔇 Additional comments (2)
dspace-server-webapp/src/main/java/org/dspace/app/rest/repository/HandleRestRepository.java (2)

115-121: Pagination adjustment logic looks good.

This change effectively prevents errors when a client requests a page that is beyond the total number of available pages. The code now checks if the requested offset exceeds the total number of handles and adjusts to the last valid page.

One minor observation about the calculation: For perfect divisibility cases (e.g., 20 handles with page size 10), the current integer division calculation (handles.size() / pageable.getPageSize()) works correctly for this use case, but it might be clearer to add a comment explaining this is intentionally using integer division.


40-40: LGTM: Import added for PageRequest.

The new import is necessary for the pagination adjustment logic introduced in the findAll method.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Collaborator

@milanmajchrak milanmajchrak left a comment

Choose a reason for hiding this comment

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

When you get wrong pageable object I think the problem could be somewhere in the UI

@Paurikova2
Copy link
Collaborator Author

@milanmajchrak
I don't think so. I checked the frontend, and if I'm correct, the findAll() request is sent from here: https://github.com/dataquest-dev/dspace-angular/blob/dtq-dev/src/app/handle-page/handle-table/handle-table.component.ts#L162. Because a search can be applied, we can't send the correct pagination until we have the search results. Therefore, this needs to be changed on the backend.

@milanmajchrak
Copy link
Collaborator

Fixed here dataquest-dev/dspace-angular#822

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

UFAL/Manage handles - There are no search results when searching by Handle

3 participants