-
Notifications
You must be signed in to change notification settings - Fork 0
refactor(workflow, request, tus): streamline request handling and workflow testing #897
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
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThe changes introduce a new Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant RequestService
participant DB
Client->>RequestService: QueryRequestData(ctx, query, filter)
RequestService->>DB: Build query from struct fields and filter
DB-->>RequestService: Return matching *models.Request or error
RequestService-->>Client: Return result
sequenceDiagram
participant Test
participant WorkflowTest
participant RequestService
Test->>WorkflowTest: GetRequest(requestID)
WorkflowTest->>RequestService: QueryRequest(ctx, ...)
RequestService-->>WorkflowTest: *models.Request or error
WorkflowTest-->>Test: *models.Request (fail test on error)
Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (6)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
core/request.go
(1 hunks)core/testing/workflow.go
(4 hunks)db/models/tus_request.go
(1 hunks)service/request.go
(3 hunks)service/tus.go
(1 hunks)service/workflow.go
(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (5)
db/models/tus_request.go (1)
db/models/request.go (1)
Request
(21-33)
service/tus.go (2)
db/models/tus_request.go (1)
TUSRequest
(17-24)core/request.go (1)
RequestFilter
(53-59)
core/testing/workflow.go (5)
core/request.go (2)
RequestService
(12-51)REQUEST_SERVICE
(10-10)core/testing/testing.go (2)
TestContext
(218-230)TB
(215-215)core/context.go (1)
GetService
(299-312)core/workflow.go (2)
WorkflowService
(49-71)WORKFLOW_SERVICE
(14-14)db/models/request.go (1)
Request
(21-33)
core/request.go (2)
core/context.go (1)
Context
(18-46)db/models/request.go (1)
Request
(21-33)
service/request.go (4)
core/request.go (1)
RequestFilter
(53-59)db/models/request.go (1)
Request
(21-33)db/models/data_models/data_models.go (1)
RequestDataModel
(3-10)db/db.go (1)
RetryOnLock
(119-154)
🔇 Additional comments (12)
service/tus.go (1)
75-77
: LGTM!The migration to
QueryRequestData
is appropriate and aligns with the enhanced querying capabilities introduced in the request service.db/models/tus_request.go (1)
19-23
: Database indexes are maintained via migrations, no changes requiredThe SQLite migration
db/migrations/sqlite/20250308183521_init.sql
already defines the unique indexes you removed from the GORM tags:
CREATE UNIQUE INDEX idx_tus_requests_tus_upload_id ON tus_requests (tus_upload_id);
CREATE UNIQUE INDEX idx_tus_requests_request_id ON tus_requests (request_id);
Since the database constraints remain in your migrations, removing the
uniqueIndex
struct tags does not affect data integrity or query performance. You can safely proceed without adding additional indexes in code.service/workflow.go (1)
802-822
: Good refactoring of metadata handling.The separation of workflow options processing and metadata marshaling improves code clarity and ensures proper data nesting. The workflow options are now correctly embedded in the
Data
field before the complete metadata is marshaled.core/request.go (1)
33-34
: Clean interface extension with modern Go syntax.The addition of
QueryRequestData
method and the update to useany
instead ofinterface{}
improve the API. The new method provides enhanced querying capabilities while maintaining backward compatibility.core/testing/workflow.go (8)
18-18
: Good addition of the request service field.Adding the
requestSvc
field to the struct is a solid improvement that will eliminate repeated service retrieval calls throughout the test methods.
24-24
: Proper initialization of the request service.The initialization follows the established pattern and correctly uses the generic
GetService
function with the appropriate service constant.Also applies to: 29-29
48-48
: Improved efficiency by using stored service.Good refactoring - using the stored
requestSvc
field instead of retrieving the service locally improves performance and consistency.
89-89
: Consistent use of stored service.The refactoring maintains consistency with the pattern established in other methods.
96-96
: Appropriate use of stored service for status retrieval.The change correctly uses the stored service instance for retrieving request status information.
119-122
: Well-designed wrapper method.The
ConvertRequestToWorkflow
method provides a clean interface for workflow conversion operations and properly delegates to the underlying workflow service.
124-128
: Appropriate test helper method.The
MustConvertRequestToWorkflow
method follows the established pattern of "Must" methods that fail the test on error, providing a convenient way to handle operations that should always succeed in test scenarios.
130-135
: Useful request retrieval helper.The
GetRequest
method provides a convenient way to retrieve requests in tests with proper error handling. This complements the existing test infrastructure well.
…kflow testing - Remove ErrDuplicateRequest and update QueryRequest signature in core/request.go - Add QueryRequestData method to request service with struct-to-map conversion - Enhance workflow testing with direct request service access - Improve TUSRequest model field definitions - Fix workflow conversion metadata handling
Summary by CodeRabbit
New Features
Refactor
Style
Chores