[WEB-2092] chore: soft delete operation#5244
Conversation
WalkthroughThis update enhances the application’s handling of soft deletions by introducing a Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant API
participant Database
participant TaskQueue
User->>API: Create Issue
API->>Database: Save Issue with "deleted_at" = null
API->>User: Return Issue
User->>API: Soft Delete Issue
API->>Database: Update Issue with current timestamp in "deleted_at"
API->>TaskQueue: Queue soft deletion of related objects
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.
Actionable comments posted: 1
Outside diff range, codebase verification and nitpick comments (3)
apiserver/plane/db/models/cycle.py (1)
119-119: Enhance deprecation notice.Consider adding a specific version number or date for removal to make the deprecation notice more actionable.
- # DEPRECATED TODO: - Remove in next release + # DEPRECATED TODO: - Remove in next release (v1.2.0 or by 2024-12-31)apiserver/plane/db/models/view.py (2)
Line range hint
44-44:
Enhance deprecation notice.Consider adding a specific version number or date for removal to make the deprecation notice more actionable.
- # DEPRECATED TODO: - Remove in next release + # DEPRECATED TODO: - Remove in next release (v1.2.0 or by 2024-12-31)
144-144: Enhance deprecation notice.Consider adding a specific version number or date for removal to make the deprecation notice more actionable.
- # DEPRECATED TODO: - Remove in next release + # DEPRECATED TODO: - Remove in next release (v1.2.0 or by 2024-12-31)
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (13)
- apiserver/plane/app/views/issue/base.py (2 hunks)
- apiserver/plane/bgtasks/deletion_task.py (1 hunks)
- apiserver/plane/bgtasks/notification_task.py (1 hunks)
- apiserver/plane/celery.py (1 hunks)
- apiserver/plane/db/migrations/0073_analyticview_deleted_at_apiactivitylog_deleted_at_and_more.py (1 hunks)
- apiserver/plane/db/mixins.py (2 hunks)
- apiserver/plane/db/models/cycle.py (1 hunks)
- apiserver/plane/db/models/issue.py (1 hunks)
- apiserver/plane/db/models/module.py (1 hunks)
- apiserver/plane/db/models/page.py (2 hunks)
- apiserver/plane/db/models/project.py (1 hunks)
- apiserver/plane/db/models/view.py (2 hunks)
- apiserver/plane/license/migrations/0004_changelog_deleted_at_instance_deleted_at_and_more.py (1 hunks)
Files skipped from review due to trivial changes (2)
- apiserver/plane/db/models/module.py
- apiserver/plane/db/models/project.py
Additional comments not posted (18)
apiserver/plane/license/migrations/0004_changelog_deleted_at_instance_deleted_at_and_more.py (1)
1-32: Migration file looks good.The migration file correctly adds a
deleted_atfield to multiple models. Ensure that the corresponding models and fields are correctly defined in the models.py file.apiserver/plane/celery.py (1)
39-42: New scheduled task configuration looks good.The new task
"check-every-day-to-delete-hard-delete"is correctly added to the task scheduling dictionary and is scheduled to run daily at midnight.apiserver/plane/db/mixins.py (4)
46-48: SoftDeletionManager class looks good.The
get_querysetmethod correctly filters out soft-deleted records by checking if thedeleted_atfield is null.
51-64: SoftDeleteModel class looks good.The
deleted_atfield is correctly defined and the class is marked as abstract.
66-81: Delete method looks good.The
deletemethod correctly handles soft deletion by setting thedeleted_attimestamp and saving the instance. It also triggers thesoft_delete_related_objectstask for related objects. The hard delete option is also correctly handled.
84-87: AuditModel class looks good.The class correctly inherits from
SoftDeleteModel, incorporating the soft deletion functionality.apiserver/plane/db/models/cycle.py (1)
119-119: Deprecation notice approved.The deprecation notice is clear and indicates the class should be removed in the next release.
apiserver/plane/db/models/view.py (2)
Line range hint
44-44:
Deprecation notice approved.The deprecation notice is clear and indicates the class should be removed in the next release.
144-144: Deprecation notice approved.The deprecation notice is clear and indicates the class should be removed in the next release.
apiserver/plane/bgtasks/deletion_task.py (2)
10-31: Soft delete function approved.The function correctly performs a soft delete on related objects.
40-158: Hard delete function approved.The function correctly performs a hard delete on objects that have been soft deleted for more than 30 days.
apiserver/plane/db/models/page.py (2)
122-122: Deprecation Notice: PageBlockThe
PageBlockclass has been marked as deprecated. Ensure that any dependencies on this class are refactored before the next release.
179-179: Deprecation Notice: PageFavoriteThe
PageFavoriteclass has been marked as deprecated. Ensure that any dependencies on this class are refactored before the next release.apiserver/plane/app/views/issue/base.py (2)
169-169: Verify the handling ofdeleted_atfield.The
deleted_atfield has been added to the fields being retrieved. Ensure that this field is correctly handled in the rest of the codebase, particularly in filtering and business logic.Verification successful
The
deleted_atfield is handled correctly.The
deleted_atfield is integrated into the filtering and business logic, as evidenced by its presence in various parts of the codebase, including model definitions and filtering conditions.
apiserver/plane/db/mixins.pyapiserver/plane/db/models/issue.pyapiserver/plane/bgtasks/deletion_task.py- Multiple migration files
Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the handling of `deleted_at` field in the codebase. # Test: Search for the usage of `deleted_at` field. Expect: Proper handling in filtering and business logic. rg --type python -A 5 $'deleted_at'Length of output: 65
Script:
#!/bin/bash # Description: Verify the handling of `deleted_at` field in the codebase. # Test: Search for the usage of `deleted_at` field. Expect: Proper handling in filtering and business logic. rg --glob '*.py' -A 5 'deleted_at'Length of output: 67879
404-404: Verify the handling ofdeleted_atfield.The
deleted_atfield has been added to the fields being returned. Ensure that this field is correctly handled in the rest of the codebase, particularly in filtering and business logic.Verification successful
The
deleted_atfield is properly handled in the codebase.The
deleted_atfield is integrated across multiple files, including migrations, models, mixins, and background tasks. It is used in filtering logic and soft deletion mechanisms, confirming its correct usage.
apiserver/plane/db/mixins.py: Soft delete mechanism.apiserver/plane/db/models/issue.py: Filtering logic.apiserver/plane/bgtasks/deletion_task.py: Background task handling.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the handling of `deleted_at` field in the codebase. # Test: Search for the usage of `deleted_at` field. Expect: Proper handling in filtering and business logic. rg --type python -A 5 $'deleted_at'Length of output: 65
Script:
#!/bin/bash # Description: Verify the handling of `deleted_at` field in the codebase. # Test: Search for the usage of `deleted_at` field. Expect: Proper handling in filtering and business logic. rg --type py -A 5 $'deleted_at'Length of output: 67875
apiserver/plane/bgtasks/notification_task.py (1)
Line range hint
138-138:
Verify the impact of removing"issue.activity.deleted"from the list of types being checked.The removal of
"issue.activity.deleted"from the list of types being checked may affect the handling of notifications for deleted issues. Ensure that this change aligns with the application's requirements and does not introduce any unintended behavior.apiserver/plane/db/migrations/0073_analyticview_deleted_at_apiactivitylog_deleted_at_and_more.py (1)
13-421: LGTM!The migration operations correctly add a
deleted_atfield to multiple models, aligning with the objective of implementing soft delete functionality.apiserver/plane/db/models/issue.py (1)
92-92: LGTM!The added filter condition
.filter(deleted_at__isnull=True)ensures that only issues that are not marked as deleted are included in the queryset, aligning with the objective of implementing soft delete functionality.
Issue Link: WEB-2092
Summary by CodeRabbit
New Features
Bug Fixes
Deprecations
Chores