Skip to content

Comments

[WEB-3048]feat: API endpoints for stickies#6335

Merged
pushya22 merged 1 commit intopreviewfrom
feat-home-stickies
Jan 7, 2025
Merged

[WEB-3048]feat: API endpoints for stickies#6335
pushya22 merged 1 commit intopreviewfrom
feat-home-stickies

Conversation

@sangeethailango
Copy link
Member

@sangeethailango sangeethailango commented Jan 7, 2025

Description

This PR will provide API endpoints for stickies

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

    • Added support for managing workspace stickies
    • Introduced new API endpoints for creating, listing, retrieving, updating, and deleting stickies within workspaces
  • Improvements

    • Enhanced workspace functionality with sticky management
    • Implemented permission-based access control for sticky operations

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 7, 2025

Walkthrough

This pull request introduces a new feature for managing "stickies" within workspaces. The implementation spans multiple files, adding a complete workflow for sticky management including serialization, URL routing, and view logic. The changes enable users to create, list, retrieve, update, and delete sticky objects within a specific workspace context, with built-in permission controls and optimized database querying.

Changes

File Change Summary
apiserver/plane/app/serializers/__init__.py Added StickySerializer to workspace imports
apiserver/plane/app/serializers/workspace.py Introduced StickySerializer for Sticky model with read-only fields and formatting improvements
apiserver/plane/app/urls/workspace.py Added two new URL patterns for sticky management (list/create and retrieve/update/delete)
apiserver/plane/app/views/__init__.py Imported WorkspaceStickyViewSet
apiserver/plane/app/views/workspace/sticky.py Created new WorkspaceStickyViewSet with comprehensive sticky management functionality

Sequence Diagram

sequenceDiagram
    participant User
    participant API
    participant WorkspaceStickyViewSet
    participant StickySerializer
    participant Sticky Model

    User->>API: Request to manage stickies
    API->>WorkspaceStickyViewSet: Route request
    WorkspaceStickyViewSet->>WorkspaceStickyViewSet: Validate permissions
    WorkspaceStickyViewSet->>StickySerializer: Serialize/Validate data
    StickySerializer->>Sticky Model: Create/Update/Delete
    Sticky Model-->>StickySerializer: Confirm operation
    StickySerializer-->>WorkspaceStickyViewSet: Return serialized data
    WorkspaceStickyViewSet-->>API: Respond with result
    API-->>User: Return response
Loading

Possibly related PRs

Suggested labels

⚙️backend, 📡api

Suggested reviewers

  • sriramveeraghanta
  • pablohashescobar
  • NarayanBavisetti

Poem

🐰 A sticky tale of code so bright,
Workspace magic taking flight!
Serializers dance, URLs sing,
Permissions guard each little thing.
Code rabbits hop with pure delight! 🚀


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

🧹 Nitpick comments (3)
apiserver/plane/app/views/workspace/sticky.py (2)

17-25: Optimize database query performance

The get_queryset method includes proper filtering and select_related, but consider adding an index on (workspace__slug, owner_id) to improve query performance.


42-46: Consider adding filtering and sorting options

The list endpoint could benefit from filtering by creation date, sorting options, and search functionality.

     def list(self, request, slug):
+        queryset = self.get_queryset()
+        # Add filtering
+        created_at = request.query_params.get('created_at')
+        if created_at:
+            queryset = queryset.filter(created_at__date=created_at)
+        # Add sorting
+        sort_by = request.query_params.get('sort_by', '-created_at')
+        queryset = queryset.order_by(sort_by)
         return self.paginate(
             request=request,
-            queryset=(self.get_queryset()),
+            queryset=queryset,
             on_results=lambda stickies: StickySerializer(stickies, many=True).data,
         )
apiserver/plane/app/urls/workspace.py (1)

254-260: Consider differentiating URL pattern names.

Both URL patterns use the same name "workspace-sticky". While this works, it's recommended to use more specific names to avoid potential confusion when using Django's URL reversing.

Consider applying this diff:

-        name="workspace-sticky",
+        name="workspace-sticky-list",
-        name="workspace-sticky",
+        name="workspace-sticky-detail",
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 0af9b09 and b098c2f.

📒 Files selected for processing (5)
  • apiserver/plane/app/serializers/__init__.py (1 hunks)
  • apiserver/plane/app/serializers/workspace.py (4 hunks)
  • apiserver/plane/app/urls/workspace.py (2 hunks)
  • apiserver/plane/app/views/__init__.py (1 hunks)
  • apiserver/plane/app/views/workspace/sticky.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: lint-apiserver
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (5)
apiserver/plane/app/serializers/__init__.py (1)

25-25: LGTM!

The addition of StickySerializer to the imports follows the established pattern.

apiserver/plane/app/views/__init__.py (1)

78-78: LGTM!

The addition of WorkspaceStickyViewSet to the imports follows the established pattern.

apiserver/plane/app/serializers/workspace.py (1)

154-164: LGTM!

The formatting changes improve readability while maintaining functionality.

Also applies to: 180-182

apiserver/plane/app/urls/workspace.py (2)

33-33: LGTM! Import follows Django's best practices.

The addition of WorkspaceStickyViewSet to the imports is well-organized and follows the existing pattern.


249-253: LGTM! URL pattern follows RESTful conventions.

The implementation follows REST API best practices with proper HTTP methods and resource-based URLs, maintaining consistency with other workspace endpoints.

@pushya22 pushya22 merged commit 742559b into preview Jan 7, 2025
10 of 11 checks passed
@pushya22 pushya22 deleted the feat-home-stickies branch January 7, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants