-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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-2092] chore: favorite delete changes #5302
Conversation
WalkthroughThe recent changes enhance the application by ensuring that user favorites are efficiently managed during the deletion of various entities such as cycles, modules, projects, pages, and views. Each relevant deletion method now includes logic to remove associated user favorites from the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant UserFavorite
participant Entity
User->>API: Request to delete Entity
API->>UserFavorite: Retrieve UserFavorite for Entity
alt UserFavorite found
API->>UserFavorite: Delete UserFavorite
end
API->>Entity: Delete Entity
API-->>User: Respond with success
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? TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Additionally, you can add CodeRabbit Configuration File (
|
There was a problem hiding this 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
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (7)
- apiserver/plane/api/views/cycle.py (2 hunks)
- apiserver/plane/api/views/module.py (2 hunks)
- apiserver/plane/api/views/project.py (2 hunks)
- apiserver/plane/app/views/cycle/base.py (1 hunks)
- apiserver/plane/app/views/module/base.py (2 hunks)
- apiserver/plane/app/views/page/base.py (2 hunks)
- apiserver/plane/app/views/view/base.py (3 hunks)
Additional comments not posted (5)
apiserver/plane/api/views/project.py (1)
360-366
: LGTM! But verify theUserFavorite
object deletion.The code changes are approved.
However, ensure that the
UserFavorite
object deletion logic is correct and there are no potential issues.Verification successful
The
UserFavorite
object deletion logic is correct and consistent across the codebase.The
UserFavorite.objects.get
followed bydelete()
pattern is used in multiple files, including the target fileapiserver/plane/api/views/project.py
, indicating that the logic is sound and follows a consistent approach.
apiserver/plane/api/views/project.py
apiserver/plane/api/views/cycle.py
apiserver/plane/api/views/module.py
apiserver/plane/app/views/page/base.py
apiserver/plane/app/views/workspace/favorite.py
apiserver/plane/app/views/view/base.py
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the `UserFavorite` object deletion logic. # Test: Search for the `UserFavorite` object deletion logic. Expect: Correct deletion logic. rg --type python -A 5 $'UserFavorite.objects.get'Length of output: 79
Script:
#!/bin/bash # Description: Verify the `UserFavorite` object deletion logic. # Test: Search for the `UserFavorite` object deletion logic. Expect: Correct deletion logic. rg --type py -A 5 'UserFavorite.objects.get'Length of output: 6370
apiserver/plane/app/views/view/base.py (2)
145-152
: LGTM! But verify theUserFavorite
object deletion.The code changes are approved.
However, ensure that the
UserFavorite
object deletion logic is correct and there are no potential issues.Verification successful
Verified: The
UserFavorite
object deletion logic is consistent and correct.The code changes are approved, and the deletion logic follows the same pattern used across the codebase.
apiserver/plane/app/views/view/base.py
lines 145-152Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the `UserFavorite` object deletion logic. # Test: Search for the `UserFavorite` object deletion logic. Expect: Correct deletion logic. rg --type python -A 5 $'UserFavorite.objects.get'Length of output: 79
Script:
#!/bin/bash # Description: Verify the `UserFavorite` object deletion logic. # Test: Search for the `UserFavorite` object deletion logic. Expect: Correct deletion logic. rg --type-add 'py:*.py' -t py -A 5 $'UserFavorite.objects.get'Length of output: 6387
449-463
: LGTM! But verify theUserFavorite
andDeployBoard
object deletion.The code changes are approved.
However, ensure that the
UserFavorite
andDeployBoard
object deletion logic is correct and there are no potential issues.Verification successful
The
UserFavorite
andDeployBoard
object deletion logic is correct.The code changes are approved.
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the `UserFavorite` and `DeployBoard` object deletion logic. # Test: Search for the `UserFavorite` and `DeployBoard` object deletion logic. Expect: Correct deletion logic. rg --type python -A 5 $'UserFavorite.objects.filter' rg --type python -A 5 $'DeployBoard.objects.get'Length of output: 161
Script:
#!/bin/bash # Description: Verify the `UserFavorite` and `DeployBoard` object deletion logic. # Test: Search for the `UserFavorite` and `DeployBoard` object deletion logic. Expect: Correct deletion logic. rg --type py -A 5 $'UserFavorite.objects.filter' rg --type py -A 5 $'DeployBoard.objects.get'Length of output: 17743
apiserver/plane/app/views/page/base.py (1)
363-376
: LGTM! But verify theDeployBoard
andUserFavorite
object deletion.The code changes are approved.
However, ensure that the
DeployBoard
andUserFavorite
object deletion logic is correct and there are no potential issues.Verification successful
The
DeployBoard
andUserFavorite
object deletion logic is correctly implemented.The code changes are approved.
DeployBoard
deletion logic:apiserver/plane/app/views/page/base.py
UserFavorite
deletion logic:apiserver/plane/app/views/page/base.py
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the `DeployBoard` and `UserFavorite` object deletion logic. # Test: Search for the `DeployBoard` and `UserFavorite` object deletion logic. Expect: Correct deletion logic. rg --type python -A 5 $'DeployBoard.objects.get' rg --type python -A 5 $'UserFavorite.objects.get'Length of output: 158
Script:
#!/bin/bash # Description: Verify the `DeployBoard` and `UserFavorite` object deletion logic. # Test: Search for the `DeployBoard` and `UserFavorite` object deletion logic. Expect: Correct deletion logic. rg --type py -A 5 $'DeployBoard.objects.get' rg --type py -A 5 $'UserFavorite.objects.get'Length of output: 18110
apiserver/plane/app/views/module/base.py (1)
447-451
: LGTM!The changes improve error handling by returning a 404 error when a module is not found.
# Delete the user favorite cycle | ||
UserFavorite.objects.get( | ||
user=request.user, | ||
entity_type="cycle", | ||
entity_identifier=pk, | ||
project_id=project_id, | ||
).delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure the existence of the favorite entry before deletion.
The code assumes that a favorite entry always exists for the user, which might not be the case. This can raise an exception if the entry is not found. Consider using filter().delete()
to avoid potential exceptions.
- UserFavorite.objects.get(
- user=request.user,
- entity_type="cycle",
- entity_identifier=pk,
- project_id=project_id,
- ).delete()
+ UserFavorite.objects.filter(
+ user=request.user,
+ entity_type="cycle",
+ entity_identifier=pk,
+ project_id=project_id,
+ ).delete()
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.
# Delete the user favorite cycle | |
UserFavorite.objects.get( | |
user=request.user, | |
entity_type="cycle", | |
entity_identifier=pk, | |
project_id=project_id, | |
).delete() | |
# Delete the user favorite cycle | |
UserFavorite.objects.filter( | |
user=request.user, | |
entity_type="cycle", | |
entity_identifier=pk, | |
project_id=project_id, | |
).delete() |
apiserver/plane/api/views/module.py
Outdated
UserFavorite.objects.get( | ||
user=request.user, | ||
entity_type="module", | ||
entity_identifier=pk, | ||
project_id=project_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for UserFavorite.objects.get
.
The UserFavorite.objects.get
call should be wrapped in a try-except block to handle potential DoesNotExist
exceptions.
- UserFavorite.objects.get(
- user=request.user,
- entity_type="module",
- entity_identifier=pk,
- project_id=project_id,
- ).delete()
+ try:
+ user_favorite = UserFavorite.objects.get(
+ user=request.user,
+ entity_type="module",
+ entity_identifier=pk,
+ project_id=project_id,
+ )
+ user_favorite.delete()
+ except UserFavorite.DoesNotExist:
+ pass # or handle the exception as needed
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.
UserFavorite.objects.get( | |
user=request.user, | |
entity_type="module", | |
entity_identifier=pk, | |
project_id=project_id, | |
try: | |
user_favorite = UserFavorite.objects.get( | |
user=request.user, | |
entity_type="module", | |
entity_identifier=pk, | |
project_id=project_id, | |
) | |
user_favorite.delete() | |
except UserFavorite.DoesNotExist: | |
pass # or handle the exception as needed |
UserFavorite.objects.get( | ||
user=request.user, | ||
entity_type="module", | ||
entity_identifier=pk, | ||
project_id=project_id, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for UserFavorite.objects.get
.
The UserFavorite.objects.get
call should be wrapped in a try-except block to handle potential DoesNotExist
exceptions.
- UserFavorite.objects.get(
- user=request.user,
- entity_type="module",
- entity_identifier=pk,
- project_id=project_id,
- ).delete()
+ try:
+ user_favorite = UserFavorite.objects.get(
+ user=request.user,
+ entity_type="module",
+ entity_identifier=pk,
+ project_id=project_id,
+ )
+ user_favorite.delete()
+ except UserFavorite.DoesNotExist:
+ pass # or handle the exception as needed
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.
UserFavorite.objects.get( | |
user=request.user, | |
entity_type="module", | |
entity_identifier=pk, | |
project_id=project_id, | |
try: | |
user_favorite = UserFavorite.objects.get( | |
user=request.user, | |
entity_type="module", | |
entity_identifier=pk, | |
project_id=project_id, | |
) | |
user_favorite.delete() | |
except UserFavorite.DoesNotExist: | |
pass # or handle the exception as needed |
apiserver/plane/api/views/cycle.py
Outdated
UserFavorite.objects.get( | ||
user=request.user, | ||
entity_type="cycle", | ||
entity_identifier=pk, | ||
project_id=project_id, | ||
).delete() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add error handling for UserFavorite.objects.get
.
The UserFavorite.objects.get
call should be wrapped in a try-except block to handle potential DoesNotExist
exceptions.
- UserFavorite.objects.get(
- user=request.user,
- entity_type="cycle",
- entity_identifier=pk,
- project_id=project_id,
- ).delete()
+ try:
+ user_favorite = UserFavorite.objects.get(
+ user=request.user,
+ entity_type="cycle",
+ entity_identifier=pk,
+ project_id=project_id,
+ )
+ user_favorite.delete()
+ except UserFavorite.DoesNotExist:
+ pass # or handle the exception as needed
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.
UserFavorite.objects.get( | |
user=request.user, | |
entity_type="cycle", | |
entity_identifier=pk, | |
project_id=project_id, | |
).delete() | |
try: | |
user_favorite = UserFavorite.objects.get( | |
user=request.user, | |
entity_type="cycle", | |
entity_identifier=pk, | |
project_id=project_id, | |
) | |
user_favorite.delete() | |
except UserFavorite.DoesNotExist: | |
pass # or handle the exception as needed |
There was a problem hiding this 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
Files selected for processing (2)
- apiserver/plane/app/views/page/base.py (1 hunks)
- apiserver/plane/app/views/view/base.py (2 hunks)
Files skipped from review as they are similar to previous changes (2)
- apiserver/plane/app/views/page/base.py
- apiserver/plane/app/views/view/base.py
There was a problem hiding this 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
Files selected for processing (7)
- apiserver/plane/api/views/cycle.py (2 hunks)
- apiserver/plane/api/views/module.py (2 hunks)
- apiserver/plane/api/views/project.py (2 hunks)
- apiserver/plane/app/views/cycle/base.py (1 hunks)
- apiserver/plane/app/views/module/base.py (2 hunks)
- apiserver/plane/app/views/page/base.py (1 hunks)
- apiserver/plane/app/views/view/base.py (2 hunks)
Files skipped from review as they are similar to previous changes (5)
- apiserver/plane/api/views/cycle.py
- apiserver/plane/api/views/module.py
- apiserver/plane/api/views/project.py
- apiserver/plane/app/views/cycle/base.py
- apiserver/plane/app/views/module/base.py
Additional comments not posted (3)
apiserver/plane/app/views/view/base.py (2)
447-453
: LGTM! Verify the integration.The logic for deleting the user favorite view is correctly implemented.
Ensure that this integration works correctly across the application.
144-150
: LGTM! Verify the integration.The logic for deleting the user favorite view is correctly implemented.
Ensure that this integration works correctly across the application.
apiserver/plane/app/views/page/base.py (1)
362-368
: LGTM! Verify the integration.The logic for deleting the user favorite page is correctly implemented.
Ensure that this integration works correctly across the application.
Verification successful
The integration of the
destroy
method inPageViewSet
is correctly set up.The
destroy
method is referenced in the URL configuration file (apiserver/plane/app/urls/page.py
), indicating that the user favorite page deletion logic is properly integrated.
apiserver/plane/app/views/page/base.py
:destroy
method implementation.apiserver/plane/app/urls/page.py
: References toPageViewSet
and itsdestroy
method.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify integration of the user favorite page deletion when a page is deleted. # Test: Search for the usage of the `destroy` method in `PageViewSet`. rg --type python -A 5 $'def destroy(self, request, slug, project_id, pk)' | rg 'PageViewSet'Length of output: 122
Script:
#!/bin/bash # Description: Verify integration of the user favorite page deletion when a page is deleted. # Test: Search for the usage of the `destroy` method in `PageViewSet`. rg --type py -A 5 $'def destroy(self, request, slug, project_id, pk)' | rg 'PageViewSet'Length of output: 87
Script:
#!/bin/bash # Description: Verify integration of the user favorite page deletion when a page is deleted. # Search for all references to the `destroy` method in the codebase. rg --type py 'destroy' # Search for all references to the `PageViewSet` class in the codebase. rg --type py 'PageViewSet'Length of output: 8032
chore:
Issue Link: WEB-2092
Summary by CodeRabbit
New Features
Bug Fixes
Chores