-
Notifications
You must be signed in to change notification settings - Fork 0
Implement Repository and InvestmentStore Interfaces for Database and Cache Operations #16
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
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.
Pull Request Overview
This PR introduces interfaces and implementations for handling investment-related operations with both database and cache, while updating data types (using primitive.ObjectID) and adding corresponding tests. Key changes include:
- New Repository and InvestmentStore interfaces for database and cache operations.
- Updates to tests and DTOs to reflect changes from string IDs to primitive.ObjectID.
- Additions and modifications in HTTP handlers and routes to support investment opportunity creation and retrieval.
Reviewed Changes
Copilot reviewed 27 out of 27 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/module/investment/repository/repository.go | New interfaces for Repository and InvestmentStore added. |
| internal/module/investment/domain/* | Domain interfaces and corresponding mocks updated. |
| internal/interfaces/http/* | Tests and HTTP handlers updated to work with ObjectID types. |
| internal/infrastructure/persistence/redis/* | Redis persistence implementations and tests for investments added. |
| internal/infrastructure/persistence/mongodb/* | MongoDB persistence implementations and tests updated with ObjectIDs. |
| internal/entities/* | Entities updated to use primitive.ObjectID for ID fields. |
| cmd/server/route.go | New route added for CreateOpportunity. |
Comments suppressed due to low confidence (2)
internal/infrastructure/persistence/mongodb/investment.go:12
- There is a typo in the type name 'MongoInvestmentResporitory'; consider renaming it to 'MongoInvestmentRepository' to improve clarity and consistency.
type MongoInvestmentResporitory struct {
internal/interfaces/http/investment.go:104
- The InvestmentResponse no longer includes the investment ID. If clients rely on this ID for identification or further operations, consider including investment.ID in the response.
- ID: investment.ID,
|
The current implementation looks good overall. As you proceed with implementing the service layer, please pay attention to ensuring the cache reflects the correct state after database operations. Given the scale of the project, we don’t need to worry too much about high-concurrency scenarios for now. To handle cases like user-initiated updates and ensure fresh data is served, it would be sufficient to simply invalidate the relevant cache entries at the time of update. |
c089b15 to
1d04662
Compare
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.
Pull Request Overview
This PR refactors the interfaces and persistence layers for investment-related operations by standardizing the use of primitive.ObjectID and by adding support for creating investment opportunities.
- Updated type definitions and conversions for IDs in investments, goals, and transactions.
- Fixed the package typo from “responde” to “respond” across multiple files.
- Added CreateOpportunity endpoints and corresponding tests for investments.
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| internal/interfaces/http/respond/respond.go | Fixed package name typo. |
| internal/interfaces/http/investment_test.go | Updated tests to use primitive.ObjectID and hex conversions. |
| internal/interfaces/http/investment_mock.go | Updated mock methods and comments. |
| internal/interfaces/http/investment.go | Added CreateOpportunity interface and updated error handling with the new “respond” package. |
| internal/interfaces/http/goals*.go, gacha.go, auth.go | Updated package name fixes and ID conversions. |
| internal/infrastructure/persistence/redis/* | Adjusted tests and methods to use primitive IDs. |
| internal/infrastructure/persistence/mongodb/* | Updated tests and repository implementations for investments and transactions. |
| internal/entities/* | Updated entity definitions to use primitive.ObjectID. |
| cmd/server/route.go | Added CreateOpportunity route. |
Comments suppressed due to low confidence (1)
internal/infrastructure/persistence/mongodb/investment.go:12
- The struct name 'MongoInvestmentResporitory' appears to be misspelled. Consider renaming it to 'MongoInvestmentRepository' for consistency and clarity.
type MongoInvestmentResporitory struct {
Description
This pull request defines interfaces for interacting with both the database and the cache for investment-related operations.
Key Features:
Repository Interface:
TransactionStore Interface:
Tests
Other Changes
entities.Investment,entities.transaction, andentities.goalsby standardizingprimitive.ObjectIDforID,OpportunityID,userIDfields.respondetorespond.