fix: delete_at not updating#6577
Conversation
WalkthroughThis pull request updates the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
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 using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (4)
apiserver/plane/bgtasks/deletion_task.py (4)
85-88: LGTM! The change fixes thedeleted_atupdate issue.The modification to use
manager="objects"ensures that the correct queryset manager is used when fetching related objects, which should resolve the issue wheredeleted_atwas not being updated for epics.However, consider adding debug logging to track the deletion process:
related_queryset = getattr(instance, related_name)( manager="objects" ).all() + print(f"Fetched {related_queryset.count()} related objects for {related_name}")
101-103: Enhance error handling with structured logging.Replace the basic print statement with proper logging to help with debugging and monitoring.
- print(f"Error handling relation {related_name}: {str(e)}") + import logging + logger = logging.getLogger(__name__) + logger.error( + "Error handling relation during soft delete", + extra={ + "relation": related_name, + "instance_type": type(instance).__name__, + "instance_id": instance.pk, + "error": str(e) + }, + exc_info=True + )
112-114: Consider implementing therestore_related_objectsfunction.The function is currently empty but might be needed for restoring soft-deleted objects. Would you like me to help implement this function to complement the soft deletion functionality?
142-220: Refactor repetitive hard deletion code.The hard deletion code has a lot of repetition. Consider refactoring it to use a more maintainable approach.
+ def delete_old_records(model): + return model.all_objects.filter( + deleted_at__lt=timezone.now() - timezone.timedelta(days=days) + ).delete() + + models_to_delete = [ + Workspace, Project, Cycle, Module, Issue, Page, IssueView, + Label, State, IssueActivity, IssueComment, IssueLink, + IssueReaction, UserFavorite, ModuleIssue, CycleIssue, + Estimate, EstimatePoint + ] + + for model in models_to_delete: + _ = delete_old_records(model)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apiserver/plane/bgtasks/deletion_task.py(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: Analyze (javascript)
- GitHub Check: Analyze (python)
Description
If an issue is archived or drafted, deleted_at was not getting updated and this PR will fix the it.
Summary by CodeRabbit