[WEB-3048]feat: API endpoints for stickies#6335
Conversation
WalkthroughThis 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
Sequence DiagramsequenceDiagram
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
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
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: 2
🧹 Nitpick comments (3)
apiserver/plane/app/views/workspace/sticky.py (2)
17-25: Optimize database query performanceThe
get_querysetmethod includes proper filtering andselect_related, but consider adding an index on(workspace__slug, owner_id)to improve query performance.
42-46: Consider adding filtering and sorting optionsThe 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
📒 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
StickySerializerto the imports follows the established pattern.apiserver/plane/app/views/__init__.py (1)
78-78: LGTM!The addition of
WorkspaceStickyViewSetto 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
WorkspaceStickyViewSetto 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.
Description
This PR will provide API endpoints for stickies
Type of Change
Summary by CodeRabbit
New Features
Improvements