Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR migrates the application from using float64 for monetary values to using the shopspring/decimal library for more precise financial calculations, and significantly improves the Docker Compose configuration with proper service orchestration and environment variable management.
- Replaces all monetary
float64fields withdecimal.Decimalfor precise financial arithmetic - Adds comprehensive Docker Compose setup with PostgreSQL and SQLite profiles, health checks, and environment variable configuration
- Refactors code structure with improved naming and reduced duplication
Reviewed Changes
Copilot reviewed 16 out of 17 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| model/items.go | Updates Item.Price field to use decimal.Decimal with appropriate validation |
| model/order.go | Changes Order.Price field to decimal.Decimal with database column type update |
| server/purchase.go | Converts price calculations to use decimal operations with float conversion for totals |
| server/item.go | Updates price response handling to convert decimals to float64 for API responses |
| promotions/promotion.go | Refactors discount calculations to use decimal arithmetic |
| promotions/promotion_test.go | Updates test data to use decimal.NewFromFloat for price initialization |
| client/client_test.go | Modifies test assertions to work with decimal price calculations |
| docker-compose.yml | Complete rewrite with PostgreSQL/SQLite profiles, health checks, and environment variables |
| cmd/run.go | Refactors flag binding with helper function and improves code organization |
| cmd/version.go | Renames function for consistency |
| cmd/cmd_test.go | Updates test to use renamed function |
| cmd/cmd.go | Adds environment prefix constant |
| Makefile | Improves DIRTY flag detection and updates Docker targets |
| Dockerfile | Updates Alpine base image version |
| go.mod | Adds shopspring/decimal dependency |
| docs/openapi/openapi.json/swagger.json | Updates API schema to reflect price field name change |
Comments suppressed due to low confidence (1)
server/purchase.go:1
- The environment variable uses PG_HOST_PORT but should use 5432 as the container port since the application connects to the database service internally, not via the host port mapping.
package server
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.