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

fix: notification count #6109

Merged
merged 1 commit into from
Nov 28, 2024
Merged

fix: notification count #6109

merged 1 commit into from
Nov 28, 2024

Conversation

NarayanBavisetti
Copy link
Collaborator

@NarayanBavisetti NarayanBavisetti commented Nov 28, 2024

fix:

  • fixed the count of the user notifications

Summary by CodeRabbit

  • New Features

    • Expanded notification access by removing restrictions based on active project membership.
    • Enhanced handling of mentions in notifications to ensure only valid project members receive updates.
  • Bug Fixes

    • Improved filtering logic for mentions and comments, reducing redundant notifications.
  • Chores

    • Updated error handling in the notification creation process for better reliability.

Copy link
Contributor

coderabbitai bot commented Nov 28, 2024

Walkthrough

The changes in this pull request involve modifications to the notification handling in two main files: base.py and notification_task.py. In base.py, a filter that restricted notifications to active project members has been removed, allowing broader access to notifications. Meanwhile, notification_task.py has been updated to enhance the logic for processing mentions and notifications, ensuring that only valid project members receive notifications related to issues and comments. Overall, these changes simplify notification retrieval and improve the accuracy of notifications sent to users.

Changes

File Path Change Summary
apiserver/plane/app/views/notification/base.py Removed filter restricting notifications to active project members, broadening notification access.
apiserver/plane/bgtasks/notification_task.py Enhanced logic for handling mentions; added UUID import, refined filtering of mentions for notifications.

Possibly related PRs

  • [WEB-2776] fix: restrict notifications #6081: This PR modifies the notification logic to restrict notifications to active project members, which is directly related to the changes in the main PR that broadens notification access by removing the active membership filter.
  • chore: restrict email notifications for removed users #6100: This PR enhances the filtering logic in the NotificationViewSet class to ensure that only active project members receive notifications, aligning with the main PR's focus on notification retrieval logic.

Suggested labels

⚙️backend

Suggested reviewers

  • pablohashescobar
  • sriramveeraghanta

Poem

In the meadow where notifications bloom,
A rabbit hops, dispelling the gloom.
With filters removed, the news flows wide,
All friends can see what’s happening inside!
So let’s celebrate, with a joyful cheer,
For every mention, we hold so dear! 🐇✨


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

🧹 Outside diff range and nitpick comments (2)
apiserver/plane/bgtasks/notification_task.py (2)

2-4: Remove redundant uuid import

The module-level import import uuid is redundant since you're directly importing UUID from the same module.

# Python imports
-import uuid
+from uuid import UUID
-from uuid import UUID

260-260: Fix line length and improve readability

The line exceeds the maximum length of 88 characters. Let's break it into multiple lines for better readability.

-                str(mention) for mention in new_mentions if mention in set(project_members)
+                str(mention)
+                for mention in new_mentions
+                if mention in set(project_members)
🧰 Tools
🪛 Ruff (0.8.0)

260-260: Line too long (91 > 88)

(E501)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e3799c8 and a35ebf5.

📒 Files selected for processing (2)
  • apiserver/plane/app/views/notification/base.py (0 hunks)
  • apiserver/plane/bgtasks/notification_task.py (3 hunks)
💤 Files with no reviewable changes (1)
  • apiserver/plane/app/views/notification/base.py
🧰 Additional context used
🪛 Ruff (0.8.0)
apiserver/plane/bgtasks/notification_task.py

260-260: Line too long (91 > 88)

(E501)

Comment on lines +292 to +296
comment_mentions = [
mention
for mention in comment_mentions
if UUID(mention) in set(project_members)
]
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add error handling for UUID conversion

The UUID conversion could raise a ValueError for invalid UUIDs. Consider adding error handling to gracefully skip invalid mentions.

                    comment_mentions = [
                        mention
                        for mention in comment_mentions
-                        if UUID(mention) in set(project_members)
+                        if _is_valid_uuid_member(mention, project_members)
                    ]

+def _is_valid_uuid_member(mention, project_members):
+    try:
+        return UUID(mention) in set(project_members)
+    except ValueError:
+        return False
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
comment_mentions = [
mention
for mention in comment_mentions
if UUID(mention) in set(project_members)
]
comment_mentions = [
mention
for mention in comment_mentions
if _is_valid_uuid_member(mention, project_members)
]
def _is_valid_uuid_member(mention, project_members):
try:
return UUID(mention) in set(project_members)
except ValueError:
return False

@pushya22 pushya22 merged commit 378e896 into preview Nov 28, 2024
13 of 15 checks passed
@pushya22 pushya22 deleted the chore/notification-count branch November 28, 2024 07:28
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