Skip to content
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

feat: update pagination to show all notification records in portal #292

Merged
15 commits merged into from
Aug 5, 2024

Conversation

kshitij-k-osmosys
Copy link
Contributor

@kshitij-k-osmosys kshitij-k-osmosys commented Jul 25, 2024

Portal PR Checklist

Pre-requisites

  • I have gone through the Contributing guidelines for Submitting a Pull Request (PR) and ensured that this is not a duplicate PR.
  • I have performed preliminary testing to ensure that any existing features are not impacted and any new features are working as expected.

PR Details

PR details have been updated as per the given format (see below)

  • PR title adheres to the format specified in guidelines (e.g., feat: add admin login page)
  • Description has been added
  • Related changes have been added (optional)
  • Screenshots have been added (optional)
  • Pending actions have been added (optional)
  • Any other additional notes have been added (optional)

Additional Information

  • Appropriate label(s) have been added (ready for review should be added if the PR is ready to be reviewed)
  • Assignee(s) and reviewer(s) have been added (optional)

Description:

Update pagination to show all notification records in the portal

Related changes:

  • Update the portal to use lazy loading for notifications
  • Update GraphQL query to return total, offset and limit
  • Update model to incorporate the above change
  • Updated the service function to return notificationResponse object
  • Now we are incrementally calling only those records for which the page is open
  • Tested the feature on local and on docker
  • Check if on page change records are updated successfully
  • Handle as many edge cases as possible

Screenshots:

image

Pending actions:

NA

Additional notes:

NA

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced notifications loading experience with lazy loading for better performance and user interaction.
    • Added flexibility in specifying the number of notifications retrieved through new limit and offset parameters in the notifications query.
    • Introduced a new interface for managing notification responses, which includes pagination metadata.
  • Bug Fixes

    • Corrected the handling of the limit parameter to allow it to be explicitly optional, improving data retrieval flexibility.

Copy link

coderabbitai bot commented Jul 25, 2024

Walkthrough

The recent updates significantly improve notification management in the application. The limit property in the QueryOptionsDto class is now explicitly optional, providing more flexibility. The GetNotifications query has been modified to include limit and offset parameters, enhancing control over notification retrieval. With the implementation of lazy loading and a refined response structure, these changes enrich user interaction and enhance overall application performance.

Changes

Files Change Summary
apps/api/src/common/graphql/dtos/query-options.dto.ts, apps/portal/src/app/graphql/graphql.queries.ts The limit property in QueryOptionsDto is optional without a default value. The GetNotifications query now requires limit and offset parameters, improving data retrieval control.
apps/portal/src/app/views/notifications/notification.model.ts A new NotificationResponse interface is introduced, encapsulating notifications along with pagination metadata.
apps/portal/src/app/views/notifications/notifications.component.html, apps/portal/src/app/views/notifications/notifications.component.ts Logic for loading notifications has been refactored to support lazy loading, enhancing performance and user experience.
apps/portal/src/app/views/notifications/notifications.service.ts The getNotifications method now returns a NotificationResponse, including total count and additional metadata.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NotificationsComponent
    participant NotificationsService
    participant Server

    User->>NotificationsComponent: Click "Load more entries"
    NotificationsComponent->>Server: Request notifications with limit and offset
    Server->>NotificationsService: Fetch notifications
    NotificationsService-->>Server: Return notifications and metadata
    Server-->>NotificationsComponent: Return notifications
    NotificationsComponent-->>User: Display additional notifications
Loading

Poem

🐰 In the meadow where the data flows,
A limit removed, see how it grows!
Fetching notifications, come one, come all,
With bunnies of data, we’ll have a ball!
Hopping through changes, so vibrant and bright,
Hooray for the freedom, oh what a delight! 🌼


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 6771e97 and c624d91.

Files selected for processing (2)
  • apps/api/src/common/graphql/dtos/query-options.dto.ts (1 hunks)
  • apps/portal/src/app/graphql/graphql.queries.ts (1 hunks)
Additional comments not posted (2)
apps/portal/src/app/graphql/graphql.queries.ts (1)

5-5: Consider potential performance issues due to unlimited data retrieval.

Removing the limit parameter can lead to performance issues if the number of notifications is very large. Consider implementing a mechanism to handle large data sets, such as pagination or lazy loading, to avoid potential performance degradation.

apps/api/src/common/graphql/dtos/query-options.dto.ts (1)

22-26: Handle undefined limit values carefully.

The removal of the default value for the limit property makes it explicitly optional. Ensure that the consuming code handles undefined values correctly to avoid potential issues.

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: 1

Outside diff range, codebase verification and nitpick comments (1)
apps/portal/src/app/views/notifications/notifications.component.html (1)

Pagination handling issue found

The onPageChange method is defined in the notifications.component.ts file, but there is no evidence of it being bound to any paginator component or event. This suggests that pagination might not be handled correctly after the removal of the (onPage) event binding in the HTML template.

  • File: apps/portal/src/app/views/notifications/notifications.component.ts

Please ensure that the onPageChange method is properly bound to the paginator component to handle pagination events correctly.

Analysis chain

Line range hint 20-20:
Verify the correctness of pagination handling.

The removal of the (onPage) event binding from the paginator suggests a shift in how pagination is managed. Ensure that pagination is still handled correctly after this change.


Let's verify how the onPageChange method is being used within the notifications.component.ts file to ensure it is correctly bound and invoked.


Let's verify if the onPageChange method is being bound to any paginator component or event within the notifications.component.ts file.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of pagination handling.

# Test: Search for pagination handling methods. Expect: Proper management in the component.
rg --type ts 'onPageChange|updateDisplayedNotifications'

Length of output: 575


Script:

#!/bin/bash
# Description: Verify the usage of the onPageChange method in the notifications.component.ts file.

# Test: Search for the onPageChange method usage. Expect: Proper binding and invocation in the component.
rg 'onPageChange' apps/portal/src/app/views/notifications/notifications.component.ts -A 5 -B 5

Length of output: 320


Script:

#!/bin/bash
# Description: Verify the binding of the onPageChange method in the notifications.component.ts file.

# Test: Search for the onPageChange method binding. Expect: Proper binding to a paginator component or event.
rg 'onPageChange' apps/portal/src/app/views/notifications/notifications.component.ts -A 10 -B 10

Length of output: 593

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between c624d91 and 4c27373.

Files selected for processing (4)
  • apps/portal/src/app/graphql/graphql.queries.ts (1 hunks)
  • apps/portal/src/app/views/notifications/notifications.component.html (3 hunks)
  • apps/portal/src/app/views/notifications/notifications.component.scss (1 hunks)
  • apps/portal/src/app/views/notifications/notifications.component.ts (3 hunks)
Files skipped from review due to trivial changes (1)
  • apps/portal/src/app/views/notifications/notifications.component.scss
Files skipped from review as they are similar to previous changes (1)
  • apps/portal/src/app/graphql/graphql.queries.ts
Additional comments not posted (6)
apps/portal/src/app/views/notifications/notifications.component.html (1)

2-6: LGTM! Verify the correctness of isNewRecordButtonEnabled.

The control bar and button for loading more entries are well-implemented. Ensure that the isNewRecordButtonEnabled property is correctly managed in the component.

Verification successful

The isNewRecordButtonEnabled property is correctly managed.

The property is appropriately set within the updateButtonEnableOrDisable method, ensuring that the button is enabled or disabled based on the state of the records.

  • isNewRecordButtonEnabled is set to false when there are no more records to load.
  • isNewRecordButtonEnabled is set to true when there are more records to load.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `isNewRecordButtonEnabled` property.

# Test: Search for the `isNewRecordButtonEnabled` property usage. Expect: Proper management in the component.
rg --type ts 'isNewRecordButtonEnabled'

Length of output: 476


Script:

#!/bin/bash
# Description: Extract the surrounding lines of code where `isNewRecordButtonEnabled` is being set to `false` and `true`.

# Extract 5 lines before and after each occurrence of `isNewRecordButtonEnabled` being set.
rg --type ts 'isNewRecordButtonEnabled = false' -A 5 -B 5
rg --type ts 'isNewRecordButtonEnabled = true' -A 5 -B 5

Length of output: 4043

apps/portal/src/app/views/notifications/notifications.component.ts (5)

136-136: LGTM! Verify the correctness of the limit property.

The update to the loadNotifications method to include a limit property is well-implemented. Ensure that the limit property is correctly managed in the component.

Verification successful

Verify the correctness of the limit property.

The limit property is correctly set in the notifications.component.ts file and passed to the GraphQL query in graphql.queries.ts. Ensure that the limit property is consistently managed and correctly utilized in the GraphQL query.

  • apps/portal/src/app/views/notifications/notifications.component.ts: Line 136
  • apps/portal/src/app/graphql/graphql.queries.ts: Lines containing limit
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `limit` property.

# Test: Search for the usage of the `limit` property. Expect: Proper management in the component.
rg --type ts 'limit'

Length of output: 2680


70-76: LGTM! Verify the correctness of the new properties.

The new properties oldTotalRecords, maxSizeLimitMap, currentLimit, and isNewRecordButtonEnabled are well-implemented. Ensure that they are correctly managed in the component.

Verification successful

The properties oldTotalRecords, maxSizeLimitMap, currentLimit, and isNewRecordButtonEnabled are used in various parts of the notifications.component.ts file. Here are the specific lines where they are used:

  • oldTotalRecords:

    • Line 70: Initialization
    • Line 76: Update
    • Line 82: Conditional check
  • maxSizeLimitMap:

    • Line 71: Initialization
    • Line 77: Conditional check
    • Line 78: Update
    • Line 80: Conditional check
  • currentLimit:

    • Line 72: Initialization
    • Line 75: Usage in variable assignment
  • isNewRecordButtonEnabled:

    • Line 73: Initialization
    • Line 79: Update
    • Line 81: Update
    • Line 82: Conditional check

These properties appear to be used in conditions and updates related to managing the loading of additional records and the state of the button for loading more notifications.

LGTM! Verify the correctness of the new properties.

The new properties oldTotalRecords, maxSizeLimitMap, currentLimit, and isNewRecordButtonEnabled are well-implemented. Ensure that they are correctly managed in the component.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the new properties.

# Test: Search for the usage of the new properties. Expect: Proper management in the component.
rg --type ts 'oldTotalRecords|maxSizeLimitMap|currentLimit|isNewRecordButtonEnabled'

Length of output: 1568


221-233: LGTM! Verify the correctness of the updateButtonEnableOrDisable method.

The new updateButtonEnableOrDisable method is well-implemented. Ensure that the method correctly manages the state of the button for loading more notifications.

Verification successful

Verification successful for updateButtonEnableOrDisable method.

The updateButtonEnableOrDisable method in apps/portal/src/app/views/notifications/notifications.component.ts correctly manages the button state for loading more notifications.

  • The method is properly implemented and handles various edge cases.
  • It is called in appropriate places within the component to ensure the button state is updated as needed.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `updateButtonEnableOrDisable` method.

# Test: Search for the `updateButtonEnableOrDisable` method implementation. Expect: Proper management in the component.
rg --type ts 'updateButtonEnableOrDisable'

Length of output: 250


Script:

#!/bin/bash
# Retrieve the full implementation and context of the `updateButtonEnableOrDisable` method.

# Print lines around the method definition to get the full implementation and its context.
rg --type ts 'updateButtonEnableOrDisable' -A 20 -B 10

Length of output: 4447


211-219: LGTM! Verify the correctness of the loadMoreNotifications method.

The new loadMoreNotifications method is well-implemented. Ensure that the method correctly handles the logic for loading additional notifications.

Verification successful

The loadMoreNotifications method is correctly implemented and interacts properly with the rest of the component.

The method correctly handles the logic for loading additional notifications, and the related variables are appropriately initialized and used.

  • Implementation of loadNotifications method is correct.
  • Initialization and usage of totalRecords and maxSizeLimitMap are appropriate.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `loadMoreNotifications` method.

# Test: Search for the `loadMoreNotifications` method implementation. Expect: Proper management in the component.
rg --type ts 'loadMoreNotifications'

Length of output: 131


Script:

#!/bin/bash
# Search for the implementation of the `loadNotifications` method in the component.
rg --type ts 'loadNotifications' -A 10

# Search for the initialization of `totalRecords` and `maxSizeLimitMap` in the component.
rg --type ts 'totalRecords' -A 5
rg --type ts 'maxSizeLimitMap' -A 5

Length of output: 8412


Line range hint 234-244:
LGTM! Verify the correctness of the onPageChange and onPageSizeChange methods.

The onPageChange and onPageSizeChange methods are well-implemented. Ensure that these methods correctly handle page change and page size change events.

Verification successful

LGTM! The onPageChange and onPageSizeChange methods correctly handle page change and page size change events by updating the displayed notifications through the updateDisplayedNotifications method.

  • onPageChange updates currentPage and calls updateDisplayedNotifications.
  • onPageSizeChange calls updateDisplayedNotifications.

Both methods ensure the displayed notifications are updated appropriately based on the current page and page size.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the correctness of the `onPageChange` and `onPageSizeChange` methods.

# Test: Search for the `onPageChange` and `onPageSizeChange` methods implementation. Expect: Proper management in the component.
rg --type ts 'onPageChange|onPageSizeChange'

Length of output: 227


Script:

#!/bin/bash
# Extract the full implementation of the `onPageChange` and `onPageSizeChange` methods from the `notifications.component.ts` file.
rg --type ts -A 10 'onPageChange|onPageSizeChange' apps/portal/src/app/views/notifications/notifications.component.ts

Length of output: 520


Script:

#!/bin/bash
# Extract the implementation of the `updateDisplayedNotifications` method from the `notifications.component.ts` file.
rg --type ts -A 10 'updateDisplayedNotifications' apps/portal/src/app/views/notifications/notifications.component.ts

Length of output: 994

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: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4c27373 and 137b529.

Files selected for processing (5)
  • apps/portal/src/app/graphql/graphql.queries.ts (2 hunks)
  • apps/portal/src/app/views/notifications/notifications.component.html (1 hunks)
  • apps/portal/src/app/views/notifications/notifications.component.scss (1 hunks)
  • apps/portal/src/app/views/notifications/notifications.component.ts (4 hunks)
  • apps/portal/src/app/views/notifications/notifications.service.ts (2 hunks)
Files skipped from review due to trivial changes (1)
  • apps/portal/src/app/views/notifications/notifications.component.scss
Files skipped from review as they are similar to previous changes (1)
  • apps/portal/src/app/views/notifications/notifications.component.html
Additional context used
Biome
apps/portal/src/app/views/notifications/notifications.service.ts

[error] 33-33: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)

GitHub Check: Lint
apps/portal/src/app/views/notifications/notifications.component.ts

[warning] 135-135:
Unexpected console statement


[warning] 271-271:
Unexpected console statement


[warning] 284-284:
Unexpected console statement


[warning] 287-287:
Unexpected console statement

Additional comments not posted (9)
apps/portal/src/app/graphql/graphql.queries.ts (2)

4-12: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to GetNotifications match the new signature.


30-41: LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to GetTotalNumberOfRecords match the new signature.

apps/portal/src/app/views/notifications/notifications.service.ts (2)

11-12: LGTM!

The interface correctly reflects the updated structure of the data returned by the GraphQL query.


Line range hint 21-32:
LGTM!

The method correctly retrieves notifications based on provided variables and handles errors appropriately.

Tools
Biome

[error] 33-33: Don't use 'Number' as a type.

Use lowercase primitives for consistency.
Safe fix: Use 'number' instead

(lint/complexity/noBannedTypes)

apps/portal/src/app/views/notifications/notifications.component.ts (5)

70-74: LGTM!

The properties are correctly defined and enhance the functionality of the component.


92-92: LGTM!

The method correctly initializes the component and handles application changes.


210-235: LGTM!

The method correctly retrieves the total number of records for the currently selected application and handles errors appropriately.


238-266: LGTM!

The method correctly appends notifications and handles errors appropriately.


295-301: LGTM!

The method correctly handles application changes and resets the state as needed.

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 137b529 and 8ca15b0.

Files selected for processing (2)
  • apps/portal/src/app/views/notifications/notifications.component.ts (4 hunks)
  • apps/portal/src/app/views/notifications/notifications.service.ts (2 hunks)
Files skipped from review as they are similar to previous changes (2)
  • apps/portal/src/app/views/notifications/notifications.component.ts
  • apps/portal/src/app/views/notifications/notifications.service.ts

@ghost
Copy link

ghost commented Jul 29, 2024

When I currently go to the last page of the "first set" of notifications fetched, it sends me back to the first page. This happens every time the last of page of current set of notifications is reached. Any way to avoid this and keep the user on the same page?

See the video below for representation (note that for testing, I set the fixedChunkSize to 20).

bug_portal-lazy-loading.mp4

@kshitij-k-osmosys kshitij-k-osmosys added the help wanted Extra attention is needed label Aug 1, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8ca15b0 and fca0883.

Files selected for processing (5)
  • apps/portal/src/app/graphql/graphql.queries.ts (2 hunks)
  • apps/portal/src/app/views/notifications/notification.model.ts (1 hunks)
  • apps/portal/src/app/views/notifications/notifications.component.html (3 hunks)
  • apps/portal/src/app/views/notifications/notifications.component.ts (8 hunks)
  • apps/portal/src/app/views/notifications/notifications.service.ts (2 hunks)
Additional comments not posted (7)
apps/portal/src/app/views/notifications/notification.model.ts (1)

14-19: LGTM! The new interface NotificationResponse is well-defined.

The interface effectively adds pagination properties to manage notification lists.

apps/portal/src/app/graphql/graphql.queries.ts (1)

4-12: LGTM! The GetNotifications query is updated correctly.

The query now includes limit and offset parameters, and the response structure is updated to support pagination.

Also applies to: 26-28

apps/portal/src/app/views/notifications/notifications.service.ts (1)

6-6: LGTM! The getNotifications method and GetNotificationsResponse interface are updated correctly.

The method now returns a NotificationResponse object with pagination metadata, and the interface includes the necessary fields.

Also applies to: 11-13, 22-33

apps/portal/src/app/views/notifications/notifications.component.ts (2)

82-82: LGTM! Initialization logic is correct.

The ngOnInit function correctly initializes the applications and calls loadNotificationsLazy with appropriate parameters.


Line range hint 122-176:
LGTM! But verify the filter logic.

The loadNotificationsLazy function correctly handles lazy loading, filtering, and error handling.

However, ensure that the filter logic works as expected, especially with the UNKNOWN channel type.

Verification successful

Filter logic verification successful.

The filter logic in the loadNotificationsLazy method correctly handles the UNKNOWN channel type by excluding it from the filters and including other channel types.

  • File: apps/portal/src/app/views/notifications/notifications.component.ts
    • Line: 119-134
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the filter logic in `loadNotificationsLazy`.

# Test: Search for the filter logic. Expect: Correct handling of `UNKNOWN` channel type.
rg --type ts 'channelType.*UNKNOWN' -A 10

Length of output: 43


Script:

#!/bin/bash
# Description: Verify the filter logic in `loadNotificationsLazy`.

# Search for the `loadNotificationsLazy` function definition and its implementation.
ast-grep --lang typescript --pattern 'function loadNotificationsLazy($_) { $$$ }'

Length of output: 83


Script:

#!/bin/bash
# Description: Verify the filter logic in `loadNotificationsLazy`.

# Search for the `loadNotificationsLazy` method definition and its implementation in TypeScript classes.
ast-grep --lang typescript --pattern 'loadNotificationsLazy($_) { $$$ }'

Length of output: 530


Script:

#!/bin/bash
# Description: Verify the filter logic in `loadNotificationsLazy`.

# Search for the `loadNotificationsLazy` method definition and its implementation in TypeScript classes.
ast-grep --lang typescript --pattern 'method_definition(name: "loadNotificationsLazy") { $$$ }'

Length of output: 576


Script:

#!/bin/bash
# Description: Verify the filter logic in `loadNotificationsLazy`.

# Search for the `loadNotificationsLazy` method definition and its implementation in TypeScript files.
rg 'loadNotificationsLazy' -A 20

Length of output: 9573

apps/portal/src/app/views/notifications/notifications.component.html (2)

14-14: LGTM! Event handlers updated correctly.

The event handlers for the dropdown components have been correctly updated to use loadNotificationsLazy, improving performance and user experience.

Also applies to: 22-22, 30-30


39-39: LGTM! Table data binding and paginator updated correctly.

The data binding for the table and the paginator settings have been correctly updated to support lazy loading, enhancing performance and user interaction.

Also applies to: 43-44, 48-48

@kshitij-k-osmosys kshitij-k-osmosys changed the title feat: fix pagination to show all notification records in the portal feat: update pagination to show all notification records in the portal Aug 4, 2024
ghost
ghost previously approved these changes Aug 5, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between fca0883 and 58b6691.

Files selected for processing (1)
  • apps/portal/src/app/views/notifications/notifications.component.ts (7 hunks)
Additional comments not posted (7)
apps/portal/src/app/views/notifications/notifications.component.ts (7)

3-6: LGTM! New imports are necessary.

The new imports for LazyLoadEvent, MessageService, and NotificationResponse are correctly used in the updated code.


82-82: LGTM! Initial call to loadNotificationsLazy is correctly set up.

The initial parameters { first: 0, rows: this.pageSize } for loadNotificationsLazy ensure that the first page of notifications is loaded with the default page size.


122-128: Ensure correct initialization of pagination variables.

The variables for pagination are correctly initialized with offset and limit from the LazyLoadEvent.


144-147: LGTM! Channel type filtering logic is correct.

The logic for filtering notifications based on the selected channel type is correctly implemented.


179-182: Ensure correct handling of notification response.

The subscription correctly updates the notifications and total records based on the response.


Line range hint 185-193:
LGTM! Methods for JSON dialog are correctly implemented.

The showJsonObject and closeJsonDialog methods are correctly implemented and maintain their functionality.


Line range hint 1-193:
LGTM! Overall structure and logic are sound.

The refactor to use lazy loading for notifications simplifies the component's state management and aligns with best practices.

@ghost ghost changed the title feat: update pagination to show all notification records in the portal feat: update pagination to show all notification records in portal Aug 5, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 58b6691 and 98930a3.

Files selected for processing (1)
  • apps/portal/src/app/views/notifications/notifications.component.ts (7 hunks)
Additional comments not posted (2)
apps/portal/src/app/views/notifications/notifications.component.ts (2)

3-6: LGTM! Import statement update is correct.

The import statement has been updated to include NotificationResponse, which is necessary for the new response structure.


Line range hint 122-184:
LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to loadNotificationsLazy match the new signature.

Verification successful

Verified: The function usage matches the new signature.

The function loadNotificationsLazy is called with the expected LazyLoadEvent parameter structure, ensuring consistency with the new implementation.

  • apps/portal/src/app/views/notifications/notifications.component.ts: this.loadNotificationsLazy({ first: 0, rows: this.pageSize });
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `loadNotificationsLazy` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type ts -A 5 $'loadNotificationsLazy'

Length of output: 1375

@ghost ghost merged commit 9e8d177 into main Aug 5, 2024
6 checks passed
@ghost ghost deleted the feat/remove-portal-limit branch August 5, 2024 11:45
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed ready for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant