Skip to content

chore: quick link migration#6274

Merged
sriramveeraghanta merged 2 commits intopreviewfrom
chore-workspace-links
Dec 24, 2024
Merged

chore: quick link migration#6274
sriramveeraghanta merged 2 commits intopreviewfrom
chore-workspace-links

Conversation

@NarayanBavisetti
Copy link
Collaborator

@NarayanBavisetti NarayanBavisetti commented Dec 24, 2024

Description

this pull request contains the migration for quick links

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Summary by CodeRabbit

  • New Features

    • Introduced a new WorkspaceUserLink model to enhance workspace management.
    • Added a sort_order field to the existing Sticky model for improved sorting functionality.
  • Bug Fixes

    • Updated entity_name field in PageLog to allow more flexible string values.
  • Improvements

    • Enhanced Sticky model with custom save logic for sort_order and added string representation method.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 24, 2024

Walkthrough

This pull request introduces database schema modifications across multiple files. A new WorkspaceUserLink model is created to facilitate workspace and user relationships. The Sticky model receives a sort_order field with custom save logic to manage sorting. The PageLog model's entity_name field has been simplified by removing choice restrictions. These changes enhance the data modeling capabilities of the application, providing more flexibility in managing workspace-related entities and sticky note ordering.

Changes

File Change Summary
apiserver/plane/db/migrations/0088_sticky_sort_order_workspaceuserlink.py - Added sort_order field to sticky model
- Created new WorkspaceUserLink model
- Modified entity_name field in pagelog model
apiserver/plane/db/models/__init__.py - Added import for WorkspaceUserLink
apiserver/plane/db/models/page.py - Removed choices from entity_name field in PageLog
apiserver/plane/db/models/sticky.py - Added sort_order field
- Implemented custom save() method
- Added __str__() method
apiserver/plane/db/models/workspace.py - Added new WorkspaceUserLink class with various fields

Suggested labels

🧹chore

Suggested reviewers

  • sriramveeraghanta
  • SatishGandham
  • pablohashescobar

Possibly related PRs

Poem

🐰 A migration's tale, so neat and bright,
Sticky notes now dance with order's might!
WorkspaceLinks spring forth with glee,
Flexibility blooms, data sets us free!
Code hops forward, one change at a time! 🚀


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37fb805 and 97281d3.

📒 Files selected for processing (1)
  • apiserver/plane/db/models/sticky.py (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apiserver/plane/db/models/sticky.py

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@NarayanBavisetti NarayanBavisetti marked this pull request as ready for review December 24, 2024 15:04
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: 4

🧹 Nitpick comments (4)
apiserver/plane/db/models/sticky.py (1)

27-27: Consider potential implications of using a float field for sorting.
Floats can introduce precision issues over time, especially if many items share similar sort values. If dynamic reorderings (e.g., drag-and-drop) are frequent, a decimal or integer-based approach is often more predictable, perhaps combined with incremental steps.

apiserver/plane/db/migrations/0088_sticky_sort_order_workspaceuserlink.py (1)

21-106: Check URL field usage and indexing for the new WorkspaceUserLink model
Providing a plain text url may suffice, but if advanced querying by URL is required, consider indexing or using a more specialized field. Also ensure that any expected quick-link validations are handled either at the model level or in forms/serializers.

apiserver/plane/db/models/workspace.py (2)

330-330: Define metadata schema for better data integrity.

The metadata JSONField should have a defined schema to ensure consistent data structure.

Add a default function that enforces the schema:

def get_default_link_metadata():
    return {
        "favicon": None,
        "last_accessed": None,
        "times_accessed": 0,
        "tags": [],
    }

Then update the field:

-    metadata = models.JSONField(default=dict)
+    metadata = models.JSONField(default=get_default_link_metadata)

327-344: Add model documentation and field descriptions.

The model lacks documentation explaining its purpose and field descriptions.

Add docstrings:

 class WorkspaceUserLink(WorkspaceBaseModel):
+    """
+    Represents a user's saved links within a workspace.
+    
+    This model stores quick links that users can save for easy access within their workspace.
+    Links can be associated with specific projects and contain metadata for enhanced functionality.
+    """
     title = models.CharField(max_length=255, null=True, blank=True)
     url = models.TextField()
     metadata = models.JSONField(default=dict)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea78c2b and 37fb805.

📒 Files selected for processing (5)
  • apiserver/plane/db/migrations/0088_sticky_sort_order_workspaceuserlink.py (1 hunks)
  • apiserver/plane/db/models/__init__.py (1 hunks)
  • apiserver/plane/db/models/page.py (1 hunks)
  • apiserver/plane/db/models/sticky.py (1 hunks)
  • apiserver/plane/db/models/workspace.py (1 hunks)
🔇 Additional comments (5)
apiserver/plane/db/models/sticky.py (1)

47-48: Str method looks good
The __str__ implementation returning self.name is clear and concise.

apiserver/plane/db/models/__init__.py (1)

71-71: Importing the new WorkspaceUserLink model
The addition here looks correctly aligned with the rest of the module imports.

apiserver/plane/db/migrations/0088_sticky_sort_order_workspaceuserlink.py (2)

16-20: Migration for sort_order field
This addition matches the model change in sticky.py and ensures a default is enforced at the database level.


107-111: Altering the entity_name for pagelog
Updating the length and verbose name appears consistent with the model changes in page.py.

apiserver/plane/db/models/page.py (1)

93-93: Ensure removal of TYPE_CHOICES is intended
Dropping the choices constraint makes entity_name fully free-form. Verify that arbitrary values won’t cause issues in related logic or processes.

@NarayanBavisetti NarayanBavisetti added ⚙️backend 🔄migrations Contains Migration changes labels Dec 24, 2024
@sriramveeraghanta sriramveeraghanta merged commit ff93688 into preview Dec 24, 2024
10 of 11 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore-workspace-links branch December 24, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

⚙️backend 🔄migrations Contains Migration changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants