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

[WEB-2854] chore: trigger issue_description_version task on issue create and update #6202

Merged
merged 2 commits into from
Dec 13, 2024

Conversation

gurusainath
Copy link
Collaborator

@gurusainath gurusainath commented Dec 13, 2024

Description

  • Implemented a trigger for the issue_description_version task to execute automatically during issue creation and update operations.
  • Ensures the issue description versions are always kept up-to-date in real-time.

Type of Change

  • Feature (non-breaking change which adds functionality)

References

[WEB-2854]

Summary by CodeRabbit

  • New Features

    • Introduced version tracking for issue descriptions to enhance issue management.
    • Added asynchronous task processing for managing issue description versions.
  • Bug Fixes

    • Improved error handling for issue description updates, ensuring data integrity.
  • Documentation

    • Updated method signatures to reflect new parameters for logging issue description versions.
  • Chores

    • Added new task imports to the application settings for better task management.

Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Walkthrough

The changes introduce a new asynchronous task, issue_description_version_task, to manage issue description versions in a Django application. This task is invoked during the creation and partial update of issues, processing updated issue data and checking for changes in descriptions. Additionally, modifications are made to the log_issue_description_version method to include more contextual parameters. Two new entries are added to the CELERY_IMPORTS for task synchronization. Overall, these changes enhance the issue management process while maintaining existing functionality.

Changes

File Path Change Summary
apiserver/plane/app/views/issue/base.py Added issue_description_version_task invocation in create and partial_update methods.
apiserver/plane/bgtasks/issue_description_version_task.py Introduced issue_description_version_task for managing issue description versions with error handling. Added methods for updating existing versions.
apiserver/plane/db/models/issue.py Updated log_issue_description_version to include new parameters for logging issue description versions.
apiserver/plane/settings/common.py Added plane.bgtasks.issue_version_sync and plane.bgtasks.issue_description_version_sync to CELERY_IMPORTS.

Possibly related PRs

Suggested labels

🌟enhancement, ⚙️backend, 🧹chore

Suggested reviewers

  • pablohashescobar
  • sriramveeraghanta

Poem

In the garden of issues, we hop with delight,
New tasks for descriptions, making things right.
With versions to track, and updates to share,
Our code blooms like flowers, with love and with care.
So let’s celebrate changes, both big and small,
For in this code garden, there's room for us all! 🐇✨


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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @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: 3

🧹 Outside diff range and nitpick comments (1)
apiserver/plane/bgtasks/issue_description_version_task.py (1)

43-45: Add type annotations to function parameters for clarity

Adding type annotations to the parameters of issue_description_version_task enhances code readability and helps with static type checking.

Apply this diff to add type annotations:

 @shared_task
 def issue_description_version_task(
-    updated_issue, issue_id, user_id, is_creating
+    updated_issue: str, issue_id: str, user_id: str, is_creating: bool
 ) -> Optional[bool]:
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between df6a80e and e9c8b58.

📒 Files selected for processing (4)
  • apiserver/plane/app/views/issue/base.py (3 hunks)
  • apiserver/plane/bgtasks/issue_description_version_task.py (1 hunks)
  • apiserver/plane/db/models/issue.py (1 hunks)
  • apiserver/plane/settings/common.py (1 hunks)
🔇 Additional comments (4)
apiserver/plane/bgtasks/issue_description_version_task.py (1)

1-84: Overall implementation is solid and handles exceptions appropriately

The task issue_description_version_task correctly processes issue description versions with proper error handling and transactional integrity.

apiserver/plane/db/models/issue.py (1)

807-813: Enhancement of log_issue_description_version with additional context

Including parameters like workspace_id, project_id, and user IDs provides better context and traceability for issue description versions. The implementation aligns well with the existing model fields.

apiserver/plane/app/views/issue/base.py (2)

61-61: Import statement correctly brings in the new task

The import of issue_description_version_task ensures the task is available for dispatching.


432-438: Triggering the versioning task after issue creation

Invoking issue_description_version_task after creating an issue ensures that the initial description version is logged appropriately.

apiserver/plane/settings/common.py Show resolved Hide resolved
apiserver/plane/app/views/issue/base.py Show resolved Hide resolved
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: 4

🧹 Outside diff range and nitpick comments (1)
apiserver/plane/bgtasks/issue_description_version_task.py (1)

54-58: Early return should indicate skip reason

Return a boolean to indicate the skip was intentional, maintaining consistency with the function's return type.

Apply this diff:

         if (
             current_issue.get("description_html") == issue.description_html
             and not is_creating
         ):
-            return
+            return True  # Skip processing as description hasn't changed
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e9c8b58 and 41d32c5.

📒 Files selected for processing (1)
  • apiserver/plane/bgtasks/issue_description_version_task.py (1 hunks)
🔇 Additional comments (3)
apiserver/plane/bgtasks/issue_description_version_task.py (3)

14-15: ⚠️ Potential issue

Ensure should_update_existing_version always returns a boolean value

The function implicitly returns None when version is None, which contradicts the boolean return type annotation.

Apply this diff:

 def should_update_existing_version(
     version: IssueDescriptionVersion, user_id: str, max_time_difference: int = 600
 ) -> bool:
     if not version:
-        return
+        return False

76-84: 🛠️ Refactor suggestion

Enhance error logging and return values

Improve error logging with more context and return False to indicate failure.

Apply this diff:

     except Issue.DoesNotExist:
-        # Issue no longer exists, skip processing
-        return
+        log_exception(f"Issue {issue_id} not found while processing description version")
+        return False
     except json.JSONDecodeError as e:
-        log_exception(f"Invalid JSON for updated_issue: {e}")
-        return
+        log_exception(
+            f"Invalid JSON for issue {issue_id}: {str(e)}",
+            extra={"updated_issue": updated_issue}
+        )
+        return False
     except Exception as e:
-        log_exception(f"Error processing issue description version: {e}")
-        return
+        log_exception(
+            f"Error processing description version for issue {issue_id}: {str(e)}",
+            extra={"user_id": user_id, "is_creating": is_creating}
+        )
+        return False

Likely invalid or redundant comment.


42-43: Verify Celery task registration

Let's ensure the task is properly registered in the Celery configuration.

✅ Verification successful

Let me generate additional verification scripts to check the Celery configuration and task registration more thoroughly.


Based on the verification results, I can now provide the final response:

Celery task integration is properly configured

The task is correctly integrated with Celery as evidenced by:

  • Task is properly decorated with @shared_task
  • Task is imported and used correctly in plane/app/views/issue/base.py
  • Celery app is configured with autodiscover_tasks() which automatically registers tasks from all Django apps
  • The task is being called correctly using .delay() method in the views
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify Celery task registration and configuration

# Check if the task is imported in Celery configuration
rg -l "issue_description_version_task" | grep -E "celery.*\.py|tasks\.py|__init__\.py"

# Check for other references to ensure proper integration
rg "issue_description_version_task" -A 3 -B 3

Length of output: 2483


Script:

#!/bin/bash
# Check Celery configuration files for task registration
fd "celery.py|__init__.py" apiserver/plane/bgtasks/ -x cat {}

# Check if the task is properly decorated and configured
ast-grep --pattern 'from celery.decorators import shared_task' 
ast-grep --pattern '@shared_task
def issue_description_version_task($$$)'

# Check for celery app configuration
fd "celery.py" apiserver/plane/ -x cat {}

Length of output: 2178

@pablohashescobar pablohashescobar merged commit 5908998 into preview Dec 13, 2024
12 of 14 checks passed
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.

2 participants