-
Notifications
You must be signed in to change notification settings - Fork 4
add create comment and reply to comment #10
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
base: main
Are you sure you want to change the base?
Conversation
WalkthroughTwo manager classes now support creating comments on issues and projects via new Changes
Sequence DiagramsequenceDiagram
participant Client
participant Manager
participant GraphQL
participant Cache
participant Response
Client->>Manager: create_comment(issue_id, body, parent_id)
Manager->>Manager: Build CreateComment mutation
Manager->>GraphQL: Execute mutation
GraphQL-->>Response: Return comment data
Manager->>Manager: Validate response
Manager->>Cache: Invalidate comment cache
Manager-->>Client: Return Comment instance
Note over Manager,Cache: On reply: parent_id included<br/>in mutation payload
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The changes introduce new GraphQL mutation logic and cache invalidation patterns across two manager classes, coupled with corresponding test coverage. While the implementations follow consistent patterns, each requires verification of correct mutation structure, response handling, and cache key invalidation. Test changes include data structure expectations that warrant careful review. Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this 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 (1)
linear_api/managers/issue_manager.py (1)
752-798: LGTM! Comment creation logic is correct.The
create_commentmethod properly executes the GraphQL mutation, validates the response, invalidates the cache, and returns a Comment instance. The support for nested replies viaparent_idis well-implemented.Optional improvements:
Address static analysis hints - Consider using
str | Noneinstead of implicitOptionalfor theparent_idparameter (line 753, PEP 484 style), and extract the error message to a constant (line 791).Reduce code duplication - The
create_commentimplementation inproject_manager.py(lines 648-695) is nearly identical. Consider extracting common logic to a base class helper method that accepts the resource type (issue vs. project) as a parameter.Example refactor for the base manager:
def _create_comment_for_resource( self, resource_id: str, body: str, resource_type: str, # "issueId" or "projectId" cache_name: str, # "comments_by_issue" or "comments_by_project" parent_id: str | None = None ) -> Comment: mutation = """ mutation CreateComment($input: CommentCreateInput!) { commentCreate(input: $input) { success comment { id body createdAt updatedAt } } } """ input_vars = {"input": {"body": body, resource_type: resource_id}} if parent_id is not None: input_vars["input"]["parentId"] = parent_id response = self._execute_query(mutation, input_vars) if ( not response or "commentCreate" not in response or not response["commentCreate"].get("comment") ): raise ValueError(f"Failed to create comment for {resource_type} {resource_id}") comment_data = response["commentCreate"]["comment"] self._cache_invalidate(cache_name, resource_id) return Comment(**comment_data)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
linear_api/managers/issue_manager.py(25 hunks)linear_api/managers/project_manager.py(23 hunks)tests/test_issue_manager.py(7 hunks)tests/test_project_manager.py(14 hunks)
🧰 Additional context used
🧬 Code graph analysis (4)
tests/test_issue_manager.py (2)
linear_api/domain/issue_models.py (1)
comments(189-201)linear_api/managers/issue_manager.py (2)
create_comment(752-798)get_comments(694-750)
tests/test_project_manager.py (4)
linear_api/domain/common_models.py (1)
Comment(23-30)linear_api/domain/project_models.py (3)
LinearProject(146-409)ProjectMilestone(34-41)comments(247-259)tests/test_integration.py (1)
client(22-31)linear_api/managers/project_manager.py (3)
create(164-217)create_comment(648-695)get_comments(596-646)
linear_api/managers/project_manager.py (3)
linear_api/domain/common_models.py (1)
Comment(23-30)linear_api/managers/base_manager.py (3)
_cache_invalidate(348-357)_execute_query(48-64)_handle_pagination(74-194)linear_api/managers/issue_manager.py (4)
create(153-219)update(222-311)create_comment(752-798)get(38-150)
linear_api/managers/issue_manager.py (4)
linear_api/domain/common_models.py (1)
Comment(23-30)linear_api/domain/issue_models.py (5)
CustomerNeedResponse(406-418)IssueRelation(396-403)LinearAttachmentInput(72-83)LinearIssue(86-310)comments(189-201)linear_api/managers/base_manager.py (3)
_handle_pagination(74-194)_cache_set(318-330)_cache_invalidate(348-357)linear_api/managers/project_manager.py (2)
create_comment(648-695)get(42-161)
🪛 Ruff (0.14.1)
linear_api/managers/project_manager.py
649-649: PEP 484 prohibits implicit Optional
Convert to T | None
(RUF013)
688-688: Avoid specifying long messages outside the exception class
(TRY003)
linear_api/managers/issue_manager.py
753-753: PEP 484 prohibits implicit Optional
Convert to T | None
(RUF013)
791-791: Avoid specifying long messages outside the exception class
(TRY003)
🔇 Additional comments (3)
linear_api/managers/project_manager.py (1)
648-695: LGTM! Project comment creation is correctly implemented.The
create_commentmethod for projects follows the same pattern as the issue version, properly handling GraphQL mutation execution, response validation, cache invalidation, and comment/reply creation.As noted in the
issue_manager.pyreview, there's an opportunity to refactor the common logic between this method andissue_manager.create_commentinto a shared base class helper. The static analysis hints (RUF013 on line 649, TRY003 on line 688) also apply here.tests/test_issue_manager.py (1)
335-361: Excellent test coverage for comment creation.The test properly validates both top-level comment creation and nested replies, including verification that both comments appear in the retrieved list. This confirms the cache invalidation and comment retrieval work correctly.
tests/test_project_manager.py (1)
285-310: Great test coverage for project comment creation.This test mirrors the issue comment test and properly validates the project comment creation and reply functionality, including verification of cache invalidation.
Summary by CodeRabbit
Release Notes