Skip to content

[NAE-2122] Implement Structured and Efficient Pagination in gRPC #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: release/7.0.0-rev4
Choose a base branch
from

Conversation

camperko
Copy link
Member

@camperko camperko commented Jul 4, 2025

Description

Fix pagination issues in paged task view.

Implements NAE-2122

Dependencies

No new dependencies were introduced

Third party dependencies

No new dependencies were introduced

Blocking Pull requests

There are no dependencies on other PR

How Has Been This Tested?

Manually tested inside of application deployed in localhost.

Name Tested on
OS Linux Mint 21
Runtime Node 20.13.1
Dependency Manager npm 10.8.0
Framework version Angular 17.3.11
Run parameters
Other configuration

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes have been checked, personally or remotely, with @...
  • I have commented my code, particularly in hard-to-understand areas
  • I have resolved all conflicts with the target branch of the PR
  • I have updated and synced my code with the target branch
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing tests pass locally with my changes:
    • Lint test
    • Unit tests
    • Integration tests
  • I have checked my contribution with code analysis tools:
  • I have made corresponding changes to the documentation:
    • Developer documentation
    • User Guides
    • Migration Guides

Summary by CodeRabbit

  • New Features

    • Improved pagination handling in task and case lists, ensuring that only the current page's items are displayed when pagination is active.
  • Refactor

    • Updated internal logic to trigger pagination immediately when new task data is set.
    • Adjusted the order of operations for pagination setup in case lists.
  • Style

    • Removed template-level slicing for task lists, relying on improved backend pagination logic.

- Enable proper task pagination handling
- Added a pagination view flag and adjusted task loading logic to properly handle paginated data in task and case views.
@camperko camperko self-assigned this Jul 4, 2025
Copy link

coderabbitai bot commented Jul 4, 2025

Walkthrough

The changes adjust pagination logic for task and case lists by moving pagination state management from Angular templates and component constructors into service-level logic. This involves setting a pagination view flag and invoking pagination methods in the services, changing how tasks are accumulated and displayed. Template-based pagination slicing is removed.

Changes

File(s) Change Summary
.../task-panel-list/task-panel-list-pagination/abstract-task-list-pagination.component.ts Setter for tasks$ now sets paginationView and calls nextPagePagination on the service before assignment.
.../case-view/components/case-list-paginator/abstract-case-list-paginator.component.ts Order of paginationView and nextPagePagination calls swapped in constructor.
.../task-view/service/task-view.service.ts Added _paginationView flag, public setter, and conditional page accumulation logic in tasksMap$ observable.
.../task-panel-list-pagination/task-list-pagination.component.html Removed template-level pagination slicing; *ngFor now iterates over all tasks.

Sequence Diagram(s)

sequenceDiagram
    participant Component as Task List Component
    participant Service as TaskViewService

    Component->>Service: Set paginationView = true
    Component->>Service: Call nextPagePagination(pageSize, pageIndex)
    Component->>Service: Assign tasks$ observable

    Service->>Service: On tasksMap$ emission
    alt paginationView is true
        Service->>Component: Emit only current page's tasks
    else
        Service->>Component: Accumulate and emit all pages' tasks
    end
Loading
sequenceDiagram
    participant Template as Angular Template
    participant Component as Task List Component

    %% Old flow
    Template->>Component: *ngFor="let task of tasks | slice:..."
    Note right of Template: Template handles pagination filtering

    %% New flow
    Template->>Component: *ngFor="let task of tasks"
    Note right of Template: All tasks provided by service, no template slicing
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
projects/netgrif-components-core/src/lib/view/task-view/service/task-view.service.ts (1)

54-54: Consider adding a getter for the pagination view state.

While the protected property and public setter provide good encapsulation, adding a public getter would improve debuggability and allow components to check the current pagination state.

+public get paginationView(): boolean {
+    return this._paginationView;
+}
projects/netgrif-components-core/src/lib/panel/task-panel-list/task-panel-list-pagination/abstract-task-list-pagination.component.ts (1)

25-32: Consider potential race conditions in the setter.

While the current implementation looks correct, repeated calls to the setter could potentially cause race conditions if the nextPagePagination method is called multiple times in quick succession before the observable pipeline completes.

Consider adding a debounce or guard to prevent multiple rapid pagination calls:

@Input()
set tasks$(tasks: Observable<Array<TaskPanelData>>) {
    if (this._isSettingTasks) {
        return;
    }
    this._isSettingTasks = true;
    this._taskViewService.paginationView = true;
    this._taskViewService.nextPagePagination(this.pageSize, this.pageIndex);
    this._tasks$ = tasks.pipe(
        tap(() => {
            this.length = this._taskViewService.pagination.totalElements;
            this.pageIndex = this._taskViewService.pagination.number;
            this._isSettingTasks = false;
        })
    );
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a536d3a and a7a7c45.

📒 Files selected for processing (4)
  • projects/netgrif-components-core/src/lib/panel/task-panel-list/task-panel-list-pagination/abstract-task-list-pagination.component.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/view/case-view/components/case-list-paginator/abstract-case-list-paginator.component.ts (1 hunks)
  • projects/netgrif-components-core/src/lib/view/task-view/service/task-view.service.ts (3 hunks)
  • projects/netgrif-components/src/lib/panel/task-panel-list-pagination/task-list-pagination.component.html (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (9)
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: task-list-completed
  • GitHub Check: Matrix Test (20)
  • GitHub Check: Matrix Test (22)
  • GitHub Check: Test with SonarCloud
  • GitHub Check: Matrix Test (24)
  • GitHub Check: task-list-completed
🔇 Additional comments (5)
projects/netgrif-components-core/src/lib/view/task-view/service/task-view.service.ts (2)

209-211: LGTM! Clean setter implementation.

The setter provides a clean interface for external components to control pagination behavior.


131-133: Service-level pagination is opt-in; existing task views are unaffected.

The _paginationView flag defaults to false and no component currently sets paginationView on TaskViewService, so the new conditional only applies when explicitly enabled. All existing templates (including those using slice for paginated views) will continue to behave as before.

projects/netgrif-components-core/src/lib/view/case-view/components/case-list-paginator/abstract-case-list-paginator.component.ts (1)

29-30: Good initialization order for pagination setup.

Setting paginationView to true before calling nextPagePagination ensures the service is properly configured for pagination mode before triggering the pagination request. This follows the same pattern as the task pagination component.

projects/netgrif-components/src/lib/panel/task-panel-list-pagination/task-list-pagination.component.html (1)

14-17: Perfect alignment with service-level pagination changes.

Removing the slice pipe from the *ngFor loop is the correct approach since the TaskViewService now handles pagination internally when paginationView is true. This eliminates redundant client-side slicing and ensures the template renders exactly what the service provides.

projects/netgrif-components-core/src/lib/panel/task-panel-list/task-panel-list-pagination/abstract-task-list-pagination.component.ts (1)

26-27: Proper pagination setup in setter.

Setting paginationView to true and calling nextPagePagination before processing the tasks observable ensures the service is configured correctly for pagination mode. This initialization order is critical for the new pagination behavior to work properly.

Copy link

sonarqubecloud bot commented Jul 4, 2025

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.

1 participant