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-1986] fix: remove the user favourites when archived a particular entity #5387

Merged
merged 3 commits into from
Aug 20, 2024

Conversation

NarayanBavisetti
Copy link
Collaborator

@NarayanBavisetti NarayanBavisetti commented Aug 20, 2024

fix:

  • This pull request implements the functionality to automatically remove user favourites when a cycle, module, project, or page is archived.

Issue Link: WEB-1986

Summary by CodeRabbit

  • New Features

    • User favorites associated with cycles, modules, projects, and pages are now automatically deleted when these entities are archived, enhancing data integrity and user experience.
  • Bug Fixes

    • Improved error handling by centralizing error codes for better maintainability and clarity, ensuring consistent responses for error scenarios.
    • Enhanced user feedback for non-existent pages with appropriate error messaging.
  • Chores

    • Removed support for the Bulk Issue Operations endpoint, reflecting a reduction in available functionalities for users interacting with project issues.

Copy link
Contributor

coderabbitai bot commented Aug 20, 2024

Walkthrough

The recent updates enhance the API server's cycle, module, and project management by ensuring that user favorites are automatically deleted when their corresponding entities are archived. This change improves data integrity and user experience by preventing stale references to inactive cycles, modules, and projects. Additionally, error handling has been streamlined across various endpoints to utilize a centralized error codes dictionary, improving maintainability and clarity in error responses.

Changes

File(s) Change Summary
apiserver/plane/api/views/{cycle,module,project}/post.py Added code to delete user favorites when a cycle, module, or project is archived, enhancing data integrity by removing stale references.
apiserver/plane/app/views/{cycle,module,page,project}/archive.py Improved error handling by replacing hardcoded error codes with a centralized ERROR_CODES dictionary, making the code more maintainable and consistent.
apiserver/plane/utils/error_codes.py Introduced a new file containing a centralized dictionary of error codes for better organization and easier reference in the application.
apiserver/plane/app/views/issue/bulk_operations.py Updated error codes in responses to use centralized definitions instead of hardcoded values, enhancing maintainability.
apiserver/plane/app/urls/issue.py Removed the BulkIssueOperationsEndpoint route, eliminating bulk operations functionality for issues.
apiserver/plane/app/views/__init__.py Removed import statement for BulkIssueOperationsEndpoint, reflecting its removal from available functionalities.
apiserver/plane/app/views/view/base.py Relaxed permission checks on retrieve and destroy methods, allowing all users to execute these functions without role-based restrictions.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant API
    participant Database

    User->>API: Archive Cycle/Module/Project
    API->>Database: Update archived_at timestamp
    Database-->>API: Confirm update
    API->>Database: Delete associated UserFavorites
    Database-->>API: Confirm deletion
    API-->>User: Success response
Loading

🐰 In the meadow, where favorites bloom,
A cycle's end casts away the gloom.
With every archive, we tidy the space,
Leaving no trace of an old favorite's face.
Errors now managed, clear as day,
Hop on, dear user, for a smoother way! 🌼


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
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 6748065 and 9203e3d.

Files selected for processing (10)
  • apiserver/plane/api/views/cycle.py (1 hunks)
  • apiserver/plane/api/views/module.py (1 hunks)
  • apiserver/plane/api/views/project.py (1 hunks)
  • apiserver/plane/app/views/cycle/archive.py (1 hunks)
  • apiserver/plane/app/views/issue/archive.py (2 hunks)
  • apiserver/plane/app/views/issue/bulk_operations.py (4 hunks)
  • apiserver/plane/app/views/module/archive.py (1 hunks)
  • apiserver/plane/app/views/page/base.py (4 hunks)
  • apiserver/plane/app/views/project/base.py (1 hunks)
  • apiserver/plane/utils/error_codes.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • apiserver/plane/utils/error_codes.py
Additional comments not posted (14)
apiserver/plane/app/views/issue/bulk_operations.py (3)

24-24: LGTM: Centralized error codes import.

The import of ERROR_CODES enhances maintainability by centralizing error code management.


76-78: LGTM: Use of centralized error codes for invalid issue dates.

Using ERROR_CODES for error handling improves consistency and maintainability.


169-171: LGTM: Use of centralized error codes for invalid issue target dates.

The usage of ERROR_CODES for error handling is consistent and maintainable.

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

50-50: LGTM: Centralized error codes import.

The import of ERROR_CODES enhances maintainability by centralizing error code management.


349-351: LGTM: Use of centralized error codes for invalid archive state group.

Using ERROR_CODES for error handling improves consistency and maintainability.

apiserver/plane/api/views/project.py (1)

380-383: LGTM: Deletion of user favorites when archiving a project.

The logic ensures that user favorites are cleaned up when a project is archived, maintaining data integrity.

apiserver/plane/app/views/page/base.py (3)

36-36: LGTM: Centralized error codes import.

The import of ERROR_CODES enhances maintainability by centralizing error code management.


308-313: LGTM: Deletion of user favorites when archiving a page.

The logic ensures that user favorites are cleaned up when a page is archived, maintaining data integrity.


528-541: LGTM: Use of centralized error codes for page lock and archive errors.

Using ERROR_CODES for error handling improves consistency and maintainability.

apiserver/plane/app/views/module/archive.py (1)

578-583: Ensure consistency in user favorite deletion logic.

The logic for deleting user favorites when a module is archived is consistent with the PR objectives. Ensure similar logic is applied consistently across other entity types as needed.

apiserver/plane/app/views/cycle/archive.py (1)

610-615: Consistency in user favorite deletion logic.

The addition of user favorite deletion logic when a cycle is archived aligns with the PR objectives. Ensure this logic is consistently applied across all relevant entity types.

apiserver/plane/api/views/module.py (1)

637-642: Consistency in user favorite deletion logic.

The addition of user favorite deletion logic when a module is archived aligns with the PR objectives. Ensure this logic is consistently applied across all relevant entity types.

apiserver/plane/app/views/project/base.py (1)

496-499: Consistency in user favorite deletion logic.

The addition of user favorite deletion logic when a project is archived aligns with the PR objectives. Ensure this logic is consistently applied across all relevant entity types.

apiserver/plane/api/views/cycle.py (1)

547-552: LGTM! Verify the deletion logic for user favorites.

The code correctly deletes user favorites associated with the cycle when it is archived. Ensure that the deletion logic covers all relevant cases.

Verify that the UserFavorite model and the deletion logic are correctly implemented and cover all necessary fields.

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 9203e3d and c9b5520.

Files selected for processing (3)
  • apiserver/plane/app/urls/issue.py (2 hunks)
  • apiserver/plane/app/views/init.py (1 hunks)
  • apiserver/plane/app/views/view/base.py (2 hunks)
Files skipped from review due to trivial changes (1)
  • apiserver/plane/app/views/init.py
Additional comments not posted (3)
apiserver/plane/app/urls/issue.py (1)

Line range hint 1-306: Verify the impact of removing BulkIssueOperationsEndpoint.

The removal of the BulkIssueOperationsEndpoint route may impact clients relying on this functionality. Ensure that this change is intentional and documented. Verify if there are any references to this endpoint elsewhere in the codebase.

Verification successful

No references to BulkIssueOperationsEndpoint found.

The search did not reveal any remaining references to BulkIssueOperationsEndpoint in the codebase, suggesting that its removal does not affect other components. Ensure that this change is intentional and properly documented to avoid potential issues.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify references to `BulkIssueOperationsEndpoint` in the codebase.

# Test: Search for references to the removed endpoint. Expect: No references remain.
rg --type python 'BulkIssueOperationsEndpoint'

Length of output: 77


Script:

#!/bin/bash
# Description: Verify references to `BulkIssueOperationsEndpoint` in the codebase.

# Test: Search for references to the removed endpoint. Expect: No references remain.
rg --type py 'BulkIssueOperationsEndpoint'

Length of output: 42

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

Line range hint 152-204: Review the removal of permission checks in destroy.

The destroy method now allows deletions without specific role or ownership checks. Ensure that this change is justified and consider the potential security implications.


Line range hint 1-152: Review the removal of role-based access control in retrieve.

The retrieve method now allows all users to execute it, regardless of their roles. Ensure that this change is intentional and consider the potential security implications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants