Skip to content

Conversation

@mertmit
Copy link
Member

@mertmit mertmit commented Jun 25, 2024

Change Summary

Only listen specific events to avoid extra overhead

Change type

  • fix: (bug fix for the user, not a fix to a build script)

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jun 25, 2024

Walkthrough

Walkthrough

The recent changes focus on enhancing event handling in the AppHooksService and NotificationsService classes by refining how event listeners are registered. Specifically, the AppHooksService now includes return types for certain event listeners, and the NotificationsService has moved from a generic event handler approach to more specific event subscriptions for PROJECT_INVITE and WELCOME events, using the appHooks.on method.

Changes

File Path Change Summary
packages/nocodb/src/services/app-hooks/app-hooks.service.ts Updated on method in AppHooksService to include return type () => void for handling certain events.
packages/nocodb/src/services/notifications/notifications.service.ts Altered NotificationsService's onModuleInit to specifically handle PROJECT_INVITE and WELCOME events instead of listening to all events.

Sequence Diagram(s)

sequenceDiagram
    participant App as AppHooksService
    participant Notification as NotificationsService
    participant Event as AppEvents

    App->>Event: Subscribe to COMMENT_CREATE
    App->>Event: Subscribe to COMMENT_UPDATE
    App->>Event: Subscribe to COMMENT_DELETE
    
    Notification->>Event: Subscribe to PROJECT_INVITE
    Notification->>Event: Subscribe to WELCOME
    
    Event-->>Notification: Trigger PROJECT_INVITE
    Notification->>Notification: handle PROJECT_INVITE

    Event-->>Notification: Trigger WELCOME
    Notification->>Notification: handle WELCOME
Loading

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 Configration 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
Contributor

@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 c00bd07 and 137af61.

Files selected for processing (2)
  • packages/nocodb/src/services/app-hooks/app-hooks.service.ts (1 hunks)
  • packages/nocodb/src/services/notifications/notifications.service.ts (1 hunks)
Additional context used
Biome
packages/nocodb/src/services/app-hooks/app-hooks.service.ts

[error] 52-52: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

Additional comments not posted (2)
packages/nocodb/src/services/notifications/notifications.service.ts (1)

245-246: Optimization of event subscriptions

The changes in the onModuleInit method to subscribe only to PROJECT_INVITE and WELCOME events align with the PR objective to reduce unnecessary overhead by avoiding listening to all events. This should enhance performance by reducing the number of handlers invoked for irrelevant events.

packages/nocodb/src/services/app-hooks/app-hooks.service.ts (1)

61-61: Clarification on return type addition

The addition of the explicit return type () => void to the on method for specific events is a good practice. It makes the API more predictable and easier to use by clearly specifying what the function returns, thereby enhancing type safety and maintainability.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 25, 2024

Uffizzi Preview deployment-53502 was deleted.

@o1lab o1lab force-pushed the nc-fix/mail-hook branch from 137af61 to 0b5c433 Compare June 26, 2024 09:23
Copy link
Contributor

@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: 2

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 137af61 and 0b5c433.

Files selected for processing (2)
  • packages/nocodb/src/services/app-hooks/app-hooks.service.ts (1 hunks)
  • packages/nocodb/src/services/notifications/notifications.service.ts (1 hunks)
Additional context used
Biome
packages/nocodb/src/services/app-hooks/app-hooks.service.ts

[error] 52-52: Decorators are not valid here. (parse)

Decorators are only valid on class declarations, class expressions, and class methods.
You can enable parameter decorators by setting the unsafeParameterDecoratorsEnabled option to true in your configuration file.

Signed-off-by: mertmit <mertmit99@gmail.com>
Copy link
Contributor

@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 0b5c433 and 9a416ac.

Files selected for processing (1)
  • packages/nocodb/src/services/notifications/notifications.service.ts (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • packages/nocodb/src/services/notifications/notifications.service.ts

@mertmit mertmit merged commit 9bb8db6 into develop Jun 26, 2024
@mertmit mertmit deleted the nc-fix/mail-hook branch June 26, 2024 11:45
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.

3 participants