Skip to content
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

chore: Add fields to issue_version and profile tables, and create new sticky table #6198

Merged
merged 3 commits into from
Dec 13, 2024

Conversation

gurusainath
Copy link
Collaborator

@gurusainath gurusainath commented Dec 13, 2024

Description

  • Added new fields to the issue_version and profile tables to enhance data handling and support additional features.
  • Created a new sticky table for managing specific data requirements.

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 new models: Sticky and IssueDescriptionVersion.
    • Added new fields to the profile model to enhance the mobile onboarding experience.
    • Implemented a new onboarding function for mobile users.
  • Bug Fixes

    • Updated field relationships and constraints in the issueversion model to improve data integrity.
  • Documentation

    • Updated import statements to include new models in the public interface.

Copy link
Contributor

coderabbitai bot commented Dec 13, 2024

Warning

Rate limit exceeded

@gurusainath has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 11 minutes and 8 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

📥 Commits

Reviewing files that changed from the base of the PR and between b308698 and c6f5c9f.

📒 Files selected for processing (1)
  • apiserver/plane/db/models/__init__.py (2 hunks)

Walkthrough

This pull request introduces significant changes to the database schema involving the issueversion and profile models. Key modifications include the removal of several fields from issueversion, the addition of new fields, and the creation of two new models: Sticky and IssueDescriptionVersion. The profile model also sees the addition of new fields aimed at enhancing mobile onboarding. Overall, these changes refine the database structure and improve relationships between models.

Changes

File Path Change Summary
apiserver/plane/db/migrations/0087_remove_issueversion_description_and_more.py - Removed fields from issueversion: description, description_binary, description_html, description_stripped.
- Added fields: activity (FK to issueactivity), point (Integer).
- Added fields to profile: is_mobile_onboarded, mobile_onboarding_step, mobile_timezone_auto_set.
- Altered owned_by in issueversion for FK relationship.
- Created models: Sticky and IssueDescriptionVersion.
apiserver/plane/db/models/__init__.py - Added import for Sticky model.
apiserver/plane/db/models/issue.py - Modified IssueVersion class: removed several fields, added activity (FK), updated point, estimate_point, type, assignees, and labels fields.
- Added IssueDescriptionVersion class with relevant fields and methods.
apiserver/plane/db/models/sticky.py - Introduced Sticky model with fields: name, description, description_html, description_stripped, description_binary, logo_props, color, background_color, workspace, owner.
apiserver/plane/db/models/user.py - Added function get_mobile_default_onboarding() and new fields in Profile: is_mobile_onboarded, mobile_onboarding_step, mobile_timezone_auto_set.

Possibly related PRs

Suggested labels

⚙️backend, 🔄migrations

Suggested reviewers

  • Narayan Bavisetti
  • Pablo Hash Escobar
  • Sriram Veeraghanta

Poem

In the database, changes bloom,
Fields removed, making room.
Stickies added, bright and new,
Mobile onboarding, just for you!
With every version, we refine,
A better structure, by design! 🐇✨


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. (Experiment)
  • @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.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


sainath seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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: 1

🧹 Outside diff range and nitpick comments (3)
apiserver/plane/db/models/sticky.py (1)

9-32: Add a __str__ method to the Sticky model

Implementing a __str__ method will enhance the readability when instances of Sticky are printed or logged.

Consider adding the following method:

def __str__(self):
    return f"{self.name} ({self.workspace})"
apiserver/plane/db/models/user.py (2)

29-35: Consider reducing code duplication with the default onboarding function.

While the implementation is correct, consider refactoring to avoid duplication with get_default_onboarding(). You could parameterize the function or use inheritance.

Here's a suggested approach:

-def get_mobile_default_onboarding():
-    return {
-        "profile_complete": False,
-        "workspace_create": False,
-        "workspace_join": False,
-    }
+def get_default_onboarding(include_workspace_invite=True):
+    steps = {
+        "profile_complete": False,
+        "workspace_create": False,
+        "workspace_join": False,
+    }
+    if include_workspace_invite:
+        steps["workspace_invite"] = False
+    return steps
+
+def get_mobile_default_onboarding():
+    return get_default_onboarding(include_workspace_invite=False)

191-191: Consider adding JSON schema validation for mobile_onboarding_step.

The mobile_onboarding_step JSONField would benefit from schema validation to ensure data consistency.

Example implementation:

from django.core.exceptions import ValidationError
import jsonschema

MOBILE_ONBOARDING_SCHEMA = {
    "type": "object",
    "properties": {
        "profile_complete": {"type": "boolean"},
        "workspace_create": {"type": "boolean"},
        "workspace_join": {"type": "boolean"}
    },
    "required": ["profile_complete", "workspace_create", "workspace_join"]
}

def validate_mobile_onboarding(value):
    try:
        jsonschema.validate(instance=value, schema=MOBILE_ONBOARDING_SCHEMA)
    except jsonschema.exceptions.ValidationError as e:
        raise ValidationError(f"Invalid mobile onboarding data: {str(e)}")

class Profile(TimeAuditModel):
    # ... other fields ...
    mobile_onboarding_step = models.JSONField(
        default=get_mobile_default_onboarding,
        validators=[validate_mobile_onboarding]
    )
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between a8140a5 and f0bb5c1.

📒 Files selected for processing (5)
  • apiserver/plane/db/migrations/0087_remove_issueversion_description_and_more.py (1 hunks)
  • apiserver/plane/db/models/__init__.py (1 hunks)
  • apiserver/plane/db/models/issue.py (4 hunks)
  • apiserver/plane/db/models/sticky.py (1 hunks)
  • apiserver/plane/db/models/user.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/db/migrations/0087_remove_issueversion_description_and_more.py

38-38: Line too long (141 > 88)

(E501)


43-43: Line too long (165 > 88)

(E501)


63-63: Line too long (141 > 88)

(E501)


68-68: Line too long (99 > 88)

(E501)


69-69: Line too long (101 > 88)

(E501)


70-70: Line too long (103 > 88)

(E501)


71-71: Line too long (140 > 88)

(E501)


79-79: Line too long (94 > 88)

(E501)


80-80: Line too long (200 > 88)

(E501)


81-81: Line too long (144 > 88)

(E501)


82-82: Line too long (206 > 88)

(E501)


83-83: Line too long (138 > 88)

(E501)


95-95: Line too long (99 > 88)

(E501)


96-96: Line too long (101 > 88)

(E501)


97-97: Line too long (103 > 88)

(E501)


98-98: Line too long (140 > 88)

(E501)


103-103: Line too long (91 > 88)

(E501)


104-104: Line too long (200 > 88)

(E501)


105-105: Line too long (142 > 88)

(E501)


106-106: Line too long (165 > 88)

(E501)


107-107: Line too long (143 > 88)

(E501)


108-108: Line too long (206 > 88)

(E501)


109-109: Line too long (149 > 88)

(E501)

apiserver/plane/db/models/issue.py

18-18: .base.BaseModel imported but unused

Remove unused import: .base.BaseModel

(F401)

🔇 Additional comments (3)
apiserver/plane/db/migrations/0087_remove_issueversion_description_and_more.py (1)

19-117: Migration script appears correct

The migration file successfully implements the intended schema changes, including adding and removing fields and creating new models. There are no issues detected in the migration operations.

🧰 Tools
🪛 Ruff (0.8.2)

38-38: Line too long (141 > 88)

(E501)


43-43: Line too long (165 > 88)

(E501)


63-63: Line too long (141 > 88)

(E501)


68-68: Line too long (99 > 88)

(E501)


69-69: Line too long (101 > 88)

(E501)


70-70: Line too long (103 > 88)

(E501)


71-71: Line too long (140 > 88)

(E501)


79-79: Line too long (94 > 88)

(E501)


80-80: Line too long (200 > 88)

(E501)


81-81: Line too long (144 > 88)

(E501)


82-82: Line too long (206 > 88)

(E501)


83-83: Line too long (138 > 88)

(E501)


95-95: Line too long (99 > 88)

(E501)


96-96: Line too long (101 > 88)

(E501)


97-97: Line too long (103 > 88)

(E501)


98-98: Line too long (140 > 88)

(E501)


103-103: Line too long (91 > 88)

(E501)


104-104: Line too long (200 > 88)

(E501)


105-105: Line too long (142 > 88)

(E501)


106-106: Line too long (165 > 88)

(E501)


107-107: Line too long (143 > 88)

(E501)


108-108: Line too long (206 > 88)

(E501)


109-109: Line too long (149 > 88)

(E501)

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

81-81: Import of Sticky model is correctly added

The Sticky model is properly imported, making it available throughout the application.

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

189-192: Verify relationship with existing onboarding fields.

The new is_mobile_onboarded field seems to overlap with the existing is_onboarded field. Consider:

  1. Documenting the distinction between these fields
  2. Whether these could be combined into a single field with an enum

apiserver/plane/db/models/issue.py Show resolved Hide resolved
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: 2

🧹 Outside diff range and nitpick comments (2)
apiserver/plane/db/migrations/0087_remove_issueversion_description_and_more.py (2)

60-86: Consider adding constraints to Sticky model fields.

The model structure is good, but consider these improvements:

  1. Add max_length to TextField name to prevent excessive long names
  2. Add validation for color fields to ensure valid color formats
-                ('name', models.TextField()),
+                ('name', models.TextField(max_length=1000)),  # adjust limit as needed
-                ('color', models.CharField(blank=True, max_length=255, null=True)),
+                ('color', models.CharField(blank=True, max_length=255, null=True, validators=[RegexValidator(r'^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$')])),
🧰 Tools
🪛 Ruff (0.8.2)

63-63: Line too long (99 > 88)

(E501)


64-64: Line too long (101 > 88)

(E501)


65-65: Line too long (103 > 88)

(E501)


66-66: Line too long (140 > 88)

(E501)


74-74: Line too long (94 > 88)

(E501)


75-75: Line too long (200 > 88)

(E501)


76-76: Line too long (144 > 88)

(E501)


77-77: Line too long (206 > 88)

(E501)


78-78: Line too long (138 > 88)

(E501)


87-111: Consider adding an index for efficient version querying.

The IssueDescriptionVersion model looks good, but consider adding an index on last_saved_at for better query performance when retrieving version history.

                 ('last_saved_at', models.DateTimeField(default=django.utils.timezone.now)),
+                models.Index(fields=['last_saved_at'], name='idx_issue_desc_version_last_saved'),
🧰 Tools
🪛 Ruff (0.8.2)

90-90: Line too long (99 > 88)

(E501)


91-91: Line too long (101 > 88)

(E501)


92-92: Line too long (103 > 88)

(E501)


93-93: Line too long (140 > 88)

(E501)


98-98: Line too long (91 > 88)

(E501)


99-99: Line too long (200 > 88)

(E501)


100-100: Line too long (142 > 88)

(E501)


101-101: Line too long (165 > 88)

(E501)


102-102: Line too long (143 > 88)

(E501)


103-103: Line too long (206 > 88)

(E501)


104-104: Line too long (149 > 88)

(E501)

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f0bb5c1 and b308698.

📒 Files selected for processing (2)
  • apiserver/plane/db/migrations/0087_remove_issueversion_description_and_more.py (1 hunks)
  • apiserver/plane/db/models/issue.py (4 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/db/models/issue.py

18-18: .base.BaseModel imported but unused

Remove unused import: .base.BaseModel

(F401)

apiserver/plane/db/migrations/0087_remove_issueversion_description_and_more.py

38-38: Line too long (141 > 88)

(E501)


58-58: Line too long (141 > 88)

(E501)


63-63: Line too long (99 > 88)

(E501)


64-64: Line too long (101 > 88)

(E501)


65-65: Line too long (103 > 88)

(E501)


66-66: Line too long (140 > 88)

(E501)


74-74: Line too long (94 > 88)

(E501)


75-75: Line too long (200 > 88)

(E501)


76-76: Line too long (144 > 88)

(E501)


77-77: Line too long (206 > 88)

(E501)


78-78: Line too long (138 > 88)

(E501)


90-90: Line too long (99 > 88)

(E501)


91-91: Line too long (101 > 88)

(E501)


92-92: Line too long (103 > 88)

(E501)


93-93: Line too long (140 > 88)

(E501)


98-98: Line too long (91 > 88)

(E501)


99-99: Line too long (200 > 88)

(E501)


100-100: Line too long (142 > 88)

(E501)


101-101: Line too long (165 > 88)

(E501)


102-102: Line too long (143 > 88)

(E501)


103-103: Line too long (206 > 88)

(E501)


104-104: Line too long (149 > 88)

(E501)

🔇 Additional comments (3)
apiserver/plane/db/migrations/0087_remove_issueversion_description_and_more.py (2)

19-39: LGTM! Migration operations for IssueVersion model are well-structured.

The removal of description fields and addition of the activity field follows Django's migration best practices.

🧰 Tools
🪛 Ruff (0.8.2)

38-38: Line too long (141 > 88)

(E501)


40-54: Verify the behavior of get_mobile_default_onboarding function.

While the mobile onboarding fields are well-structured, ensure that the get_mobile_default_onboarding function:

  1. Returns a consistent default value
  2. Handles any potential exceptions
  3. Is lightweight as it will be called for each new profile
✅ Verification successful

Function implementation verified - safe and consistent

The get_mobile_default_onboarding function is well-implemented:

  1. Returns a consistent, static dictionary with boolean flags
  2. No exception paths or complex logic that could fail
  3. Lightweight implementation with simple dictionary construction
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find the implementation of get_mobile_default_onboarding
ast-grep --pattern 'def get_mobile_default_onboarding():
  $$$'

Length of output: 446

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

18-18: Remove unused import.

The BaseModel import is not used in this file.

🧰 Tools
🪛 Ruff (0.8.2)

18-18: .base.BaseModel imported but unused

Remove unused import: .base.BaseModel

(F401)

apiserver/plane/db/models/issue.py Show resolved Hide resolved
apiserver/plane/db/models/issue.py Show resolved Hide resolved
@sriramveeraghanta sriramveeraghanta merged commit 6ff258c into preview Dec 13, 2024
11 of 14 checks passed
@sriramveeraghanta sriramveeraghanta deleted the chore_issue_version_migration branch December 13, 2024 12:00
@coderabbitai coderabbitai bot mentioned this pull request Dec 15, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants