fix: workspace user property migration#5908
Conversation
|
Warning Rate limit exceeded@NarayanBavisetti has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 17 minutes and 6 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes involve modifications to a Django migration script located in Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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
🧹 Outside diff range and nitpick comments (3)
apiserver/plane/db/migrations/0053_auto_20240102_1315.py (3)
Line range hint
30-47: Add logging for skipped records and null checksThe function silently skips IssueProperty records without matching ProjectMember entries. Consider:
- Adding logging to track skipped records
- Adding null checks for view_props access
Here's a suggested improvement:
for issue_property in IssueProperty.objects.all(): project_member = ProjectMember.objects.filter( project_id=issue_property.project_id, member_id=issue_property.user_id, ).first() if project_member: - issue_property.filters = project_member.view_props.get("filters") - issue_property.display_filters = project_member.view_props.get( - "display_filters" - ) + view_props = project_member.view_props or {} + issue_property.filters = view_props.get("filters", {}) + issue_property.display_filters = view_props.get("display_filters", {}) updated_issue_user_properties.append(issue_property) + else: + print(f"No ProjectMember found for IssueProperty {issue_property.id}")
Line range hint
53-69: Standardize batch size and add data validationThe implementation has several potential improvements:
- The batch_size (100) is inconsistent with other functions (2000)
- Missing handling of existing records
- No validation for nullable fields
Consider applying these improvements:
def issue_view(apps, schema_editor): GlobalView = apps.get_model("db", "GlobalView") IssueView = apps.get_model("db", "IssueView") updated_issue_views = [] for global_view in GlobalView.objects.all(): + # Skip if view already exists + if IssueView.objects.filter( + workspace_id=global_view.workspace_id, + name=global_view.name + ).exists(): + continue + updated_issue_views.append( IssueView( workspace_id=global_view.workspace_id, name=global_view.name, - description=global_view.description, + description=global_view.description or "", query=global_view.query, access=global_view.access, filters=global_view.query_data.get("filters", {}), sort_order=global_view.sort_order, created_by_id=global_view.created_by_id, updated_by_id=global_view.updated_by_id, ) ) - IssueView.objects.bulk_create(updated_issue_views, batch_size=100) + IssueView.objects.bulk_create(updated_issue_views, batch_size=2000)
Line range hint
78-84: Add reverse migration handlersThe migration operations don't include reverse handlers, which could make it difficult to rollback changes if needed.
Consider adding reverse handlers to each RunPython operation:
operations = [ - migrations.RunPython(workspace_user_properties), - migrations.RunPython(project_user_properties), - migrations.RunPython(issue_view), + migrations.RunPython( + workspace_user_properties, + reverse_code=migrations.RunPython.noop + ), + migrations.RunPython( + project_user_properties, + reverse_code=migrations.RunPython.noop + ), + migrations.RunPython( + issue_view, + reverse_code=migrations.RunPython.noop + ), ]
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- apiserver/plane/db/migrations/0053_auto_20240102_1315.py (3 hunks)
🔇 Additional comments (1)
apiserver/plane/db/migrations/0053_auto_20240102_1315.py (1)
Line range hint
7-24: Consider handling existing records and data validationThe migration creates new WorkspaceUserProperties records but doesn't handle potential existing records or validate view_props data. Consider:
- Adding a check for existing records to prevent duplicates
- Adding data validation for view_props to handle None/null values
Let's verify if there are any existing records:
fix:
Summary by CodeRabbit