Skip to content

chore: user workspace api modification#6547

Merged
sangeethailango merged 3 commits intofeat-enchanced-workspace-switcherfrom
feat-users-workspace-api-modification
Feb 5, 2025
Merged

chore: user workspace api modification#6547
sangeethailango merged 3 commits intofeat-enchanced-workspace-switcherfrom
feat-users-workspace-api-modification

Conversation

@sangeethailango
Copy link
Member

@sangeethailango sangeethailango commented Feb 5, 2025

Description

This PR will return the user role in the user workspace API.

Summary by CodeRabbit

  • New Features
    • Enhanced workspace data now provides user role details for improved context, replacing previous owner information in workspace overviews.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Walkthrough

This update modifies the workspace data structure by removing the owner field and adding a new read-only role field in the workspace serializer. Additionally, the user workspace endpoint is updated to annotate the queryset with the user role by querying the WorkspaceMember model, with accompanying import updates for date extraction functions. These changes adjust the output data for workspaces to now include user role information.

Changes

File(s) Change summary
apiserver/.../serializers/workspace.py Removed the owner field; added a read-only role field in the WorkSpaceSerializer.
apiserver/.../views/workspace/base.py Enhanced UserWorkSpacesEndpoint by annotating the queryset with the role from WorkspaceMember and updated import statements for date functions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Endpoint as UserWorkSpacesEndpoint
    participant DB as WorkspaceMember Database
    participant Serializer as WorkSpaceSerializer

    Client->>Endpoint: GET /user/workspaces
    Endpoint->>DB: Query workspaces with role (filter by user & active status)
    DB-->>Endpoint: Return workspace member data with role
    Endpoint->>Serializer: Serialize workspace data with new role field
    Serializer-->>Endpoint: Return serialized data
    Endpoint-->>Client: Response with updated workspace info
Loading

Possibly related PRs

Suggested labels

⚙️backend, 🧹chore

Suggested reviewers

  • NarayanBavisetti
  • sriramveeraghanta

Poem

In fields of code, I hop with glee,
New roles sprout like carrots for me.
No more owners, only roles in sight,
Guiding workspaces with insight so bright.
Happy hops in every byte—let’s code all night! 🐇

Tip

🌐 Web search-backed reviews and chat
  • We have enabled web search-based reviews and chat for all users. This feature allows CodeRabbit to access the latest documentation and information on the web.
  • You can disable this feature by setting web_search: false in the knowledge_base settings.
  • Please share any feedback in the Discord discussion.
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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.

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

🧹 Nitpick comments (2)
apiserver/plane/app/serializers/workspace.py (1)

49-57: Remove owner from read_only_fields.

The owner field has been removed from the serializer but is still listed in read_only_fields. This could cause confusion for future maintenance.

Apply this diff to remove the redundant field:

    read_only_fields = [
        "id",
        "created_by",
        "updated_by",
        "created_at",
        "updated_at",
-       "owner",
        "logo_url",
    ]
apiserver/plane/app/views/workspace/base.py (1)

178-181: Fix line length to comply with PEP 8.

The line exceeds the maximum line length of 88 characters.

Apply this diff to fix the line length:

        role = (
-            WorkspaceMember.objects.filter(workspace=OuterRef("id"), member=request.user, is_active=True)
+            WorkspaceMember.objects.filter(
+                workspace=OuterRef("id"),
+                member=request.user,
+                is_active=True
+            )
            .values("role")
        )
🧰 Tools
🪛 Ruff (0.8.2)

179-179: Line too long (105 > 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 99f3d58 and c4b4caf.

📒 Files selected for processing (2)
  • apiserver/plane/app/serializers/workspace.py (1 hunks)
  • apiserver/plane/app/views/workspace/base.py (3 hunks)
🧰 Additional context used
🪛 Ruff (0.8.2)
apiserver/plane/app/views/workspace/base.py

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

(E501)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)

@sangeethailango sangeethailango self-assigned this Feb 5, 2025
@sangeethailango sangeethailango changed the base branch from preview to feat-enchanced-workspace-switcher February 5, 2025 14:04
@sangeethailango sangeethailango merged commit 8623bea into feat-enchanced-workspace-switcher Feb 5, 2025
12 of 14 checks passed
@aheckmann aheckmann deleted the feat-users-workspace-api-modification branch April 29, 2025 23:07
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.

2 participants