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-2935] fix: search issues endpoint #6291

Merged
merged 1 commit into from
Dec 31, 2024
Merged

Conversation

NarayanBavisetti
Copy link
Collaborator

@NarayanBavisetti NarayanBavisetti commented Dec 30, 2024

Description

This pull request resolves the issue with searching for relations. Once a relation is removed, the user can add the same issue again.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Summary by CodeRabbit

  • Bug Fixes

    • Improved issue relation handling in search and relation management
    • Enhanced filtering of issues based on their relationships
  • Refactor

    • Simplified logic for removing issue relations
    • Updated search endpoint to more efficiently handle issue relationships

Copy link
Contributor

coderabbitai bot commented Dec 30, 2024

Walkthrough

The pull request introduces modifications to the issue relation handling in two files: apiserver/plane/app/views/issue/relation.py and apiserver/plane/app/views/search/issue.py. In the relation.py file, the remove_relation method is refactored to use a more generalized approach for retrieving and deleting issue relations. The issue.py file adds support for filtering issues based on their relationships by importing the IssueRelation model and implementing a new filtering mechanism.

Changes

File Change Summary
apiserver/plane/app/views/issue/relation.py - Simplified remove_relation method logic
- Removed relation_type variable
- Generalized query for finding and deleting issue relations
apiserver/plane/app/views/search/issue.py - Added import for IssueRelation model
- Enhanced issue filtering logic to handle issue relations

Possibly related PRs

Suggested labels

⚙️backend, 🌟improvement

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham

Poem

🐰 Hopping through code with glee,
Relations simplified, now we're free!
No more complex paths to roam,
Issue connections find their home
With logic clean and swift to see! 🔗

Tip

CodeRabbit's docstrings feature is now available as part of our Early Access Program! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


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. (Beta)
  • @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.

@NarayanBavisetti NarayanBavisetti linked an issue Dec 30, 2024 that may be closed by this pull request
1 task
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

🧹 Nitpick comments (1)
apiserver/plane/app/views/search/issue.py (1)

54-54: Line length exceeds style guideline.
To adhere to style guidelines (88 chars limit), shorten this line.

- related_issue_ids = [item for sublist in related_issue_ids for item in sublist]
+related_issue_ids = [
+    item
+    for sublist in related_issue_ids
+    for item in sublist
+]
🧰 Tools
🪛 Ruff (0.8.2)

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

(E501)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 94f421f and 81c88ea.

📒 Files selected for processing (2)
  • apiserver/plane/app/views/issue/relation.py (1 hunks)
  • apiserver/plane/app/views/search/issue.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/search/issue.py

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

(E501)

🔇 Additional comments (6)
apiserver/plane/app/views/search/issue.py (3)

10-10: Importing IssueRelation is appropriate.
Thanks for adding IssueRelation to better handle issue relationships within search functionality.


48-55: Filter logic to retrieve related issue IDs is correct.
This snippet correctly ensures that both directions of the relationship (Q(issue=issue) or Q(related_issue=issue)) are considered. Flattening the tuples with a list comprehension is also a neat approach.

🧰 Tools
🪛 Ruff (0.8.2)

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

(E501)


59-59: Good approach to exclude already-related issues.
This condition avoids re-introducing an existing relationship, aligning with the PR’s objective to allow re-adding issues once relationships are removed.

apiserver/plane/app/views/issue/relation.py (3)

273-280: Query logic is straightforward, but confirm the need to delete one or multiple matches.
After filtering for matching issue relations, consider whether you want to remove all found relations or just the first.

Please confirm:

  1. If only the first matching relation should be deleted, this is correct.
  2. Otherwise, remove .first() and call .delete() on the entire queryset.

282-282: Serializing the existing relation prior to deletion is a good practice.
Storing the JSON-encoded representation of the relation ensures an audit trail for potential rollbacks or analyses later.


284-284: Deleting the relation aligns with simplified logic.
You’ve removed type-based handling, opting for a single, unified approach. Ensure that the usage of .first() above still meets your functional requirements.

@pushya22 pushya22 changed the title [WEB-2935] chore: search issues endpoint [WEB-2935] fix: search issues endpoint Dec 31, 2024
@pushya22 pushya22 added the 🐛bug Something isn't working label Dec 31, 2024
@pushya22 pushya22 merged commit 119d46d into preview Dec 31, 2024
12 of 14 checks passed
@pushya22 pushya22 deleted the chore-search-issues branch December 31, 2024 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: Unable to Search Issues for Re-linking After Relationship Removal
3 participants