Skip to content

Conversation

ryanaidilp
Copy link
Contributor

Summary

This PR enhances the COVID-19 API with improved JSON structure for national endpoints and resolves database connection reliability issues.

🔄 National Endpoint Changes (BREAKING)

  • Restructured JSON Response: Organized data into logical nested groups:
    • daily: New cases for the day
    • cumulative: Total accumulated cases
    • statistics: Percentages and reproduction rates
  • English Keys: Converted all field names from Indonesian to English
  • Calculated Fields: Added active cases and percentage calculations
  • Better Organization: Grouped related data for easier consumption

🔧 Database Reliability Improvements

  • Fixed Connection Resets: Changed production DB host to 127.0.0.1
  • Enhanced Connection Pooling: Optimized timeouts and lifetimes
  • Retry Logic: Added exponential backoff for failed connections
  • Health Monitoring: Enhanced health check with DB connectivity status

🛠️ Infrastructure Enhancements

  • Ruby Changelog Generator: Automated changelog generation for releases
  • Production Configuration: Optimized settings for shared hosting
  • Comprehensive Testing: Updated tests for new response structures

📋 Breaking Changes

National endpoints (/api/v1/national, /api/v1/national/latest) now return a new JSON structure. See CHANGELOG.md for migration guide.

🧪 Testing

  • All unit tests pass
  • Integration tests updated and passing
  • Database connection improvements tested
  • New response structure validated

Ready for review and testing! 🚀

BREAKING CHANGE: Complete restructuring of national endpoints response format
- Create new response DTOs with nested structure for better organization
- Group related data into logical sections (daily, cumulative, statistics)
- Add calculated fields for active cases and percentages
- Include reproduction rate in nested statistics object
- Change all keys from Indonesian to English for better accessibility
- Add comprehensive unit tests for transformation logic
- Document all breaking changes and migration guide
Affected endpoints:
- GET /api/national
- GET /api/national/latest
- GET /api/national?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
The new structure provides:
- Better organization with nested objects for related data
- Pre-calculated statistics (active cases, percentages)
- Clearer English naming conventions
- Future-proof design for additional statistics
Refer to BREAKING_CHANGES.md for detailed migration guide.
### National Endpoint Changes:
- Restructure JSON response with nested groups (daily, cumulative, statistics)
- Convert Indonesian keys to English for better accessibility
- Add calculated fields (active cases, percentages)
- Include reproduction rate with proper bounds
### Database Connection Improvements:
- Change production DB host to 127.0.0.1 to fix connection resets
- Enhance connection pooling with shorter lifetimes and idle timeouts
- Add retry logic with exponential backoff for failed connections
- Implement connection health monitoring
### Infrastructure:
- Add Ruby-based changelog generator for release automation
- Enhanced health check endpoint with database connectivity status
- Update environment configuration for production stability
- Comprehensive test coverage for new response structures
BREAKING CHANGE: National endpoints now return nested JSON structure
Fix all linting errors identified by golangci-lint:
- Add proper error handling for unchecked error returns (errcheck)
- Remove unnecessary embedded field selectors (staticcheck)
- Implement proper defer error handling for database and HTTP resources
- Update JSON encoding to handle potential errors in response handlers
- Improve connection cleanup in database operations and tests
All tests pass after these fixes, maintaining code functionality
while ensuring compliance with Go linting standards.
@ryanaidilp ryanaidilp force-pushed the feature/update-national-json-structure branch from a817399 to b1f6ccf Compare September 7, 2025 08:05
@ryanaidilp ryanaidilp self-assigned this Sep 7, 2025
CI Configuration Changes:
- Update Go version from 1.23.x to 1.25.x in both test and lint jobs
- Resolves golangci-lint compatibility issues with Go 1.24 vs 1.25
CORS Fix:
- Add OPTIONS method support to all API routes in routes.go
- Fixes TestAPI_CORS test that was failing with 404 for OPTIONS requests
- Gorilla Mux requires explicit OPTIONS method registration for CORS preflight
- CORS middleware now properly handles preflight requests
All integration and unit tests now pass.
@ryanaidilp ryanaidilp force-pushed the feature/update-national-json-structure branch from c18611c to ed8d6d4 Compare September 7, 2025 08:21
@ryanaidilp ryanaidilp merged commit 2eb9d0e into develop Sep 7, 2025
2 checks passed
@ryanaidilp ryanaidilp deleted the feature/update-national-json-structure branch September 7, 2025 08:31
ryanaidilp added a commit that referenced this pull request Sep 7, 2025
…ty (#1)

* feat!: restructure national COVID-19 API response to nested JSON format
BREAKING CHANGE: Complete restructuring of national endpoints response format
- Create new response DTOs with nested structure for better organization
- Group related data into logical sections (daily, cumulative, statistics)
- Add calculated fields for active cases and percentages
- Include reproduction rate in nested statistics object
- Change all keys from Indonesian to English for better accessibility
- Add comprehensive unit tests for transformation logic
- Document all breaking changes and migration guide
Affected endpoints:
- GET /api/national
- GET /api/national/latest
- GET /api/national?start_date=YYYY-MM-DD&end_date=YYYY-MM-DD
The new structure provides:
- Better organization with nested objects for related data
- Pre-calculated statistics (active cases, percentages)
- Clearer English naming conventions
- Future-proof design for additional statistics
Refer to BREAKING_CHANGES.md for detailed migration guide.
* feat: improve national endpoint JSON structure and database reliability
### National Endpoint Changes:
- Restructure JSON response with nested groups (daily, cumulative, statistics)
- Convert Indonesian keys to English for better accessibility
- Add calculated fields (active cases, percentages)
- Include reproduction rate with proper bounds
### Database Connection Improvements:
- Change production DB host to 127.0.0.1 to fix connection resets
- Enhance connection pooling with shorter lifetimes and idle timeouts
- Add retry logic with exponential backoff for failed connections
- Implement connection health monitoring
### Infrastructure:
- Add Ruby-based changelog generator for release automation
- Enhanced health check endpoint with database connectivity status
- Update environment configuration for production stability
- Comprehensive test coverage for new response structures
BREAKING CHANGE: National endpoints now return nested JSON structure
* fix: resolve golangci-lint issues to pass CI
Fix all linting errors identified by golangci-lint:
- Add proper error handling for unchecked error returns (errcheck)
- Remove unnecessary embedded field selectors (staticcheck)
- Implement proper defer error handling for database and HTTP resources
- Update JSON encoding to handle potential errors in response handlers
- Improve connection cleanup in database operations and tests
All tests pass after these fixes, maintaining code functionality
while ensuring compliance with Go linting standards.
* fix: update CI to use Go 1.23 and fix golangci-lint version compatibility
* fix: update CI to use Go 1.25 and resolve CORS test failures
CI Configuration Changes:
- Update Go version from 1.23.x to 1.25.x in both test and lint jobs
- Resolves golangci-lint compatibility issues with Go 1.24 vs 1.25
CORS Fix:
- Add OPTIONS method support to all API routes in routes.go
- Fixes TestAPI_CORS test that was failing with 404 for OPTIONS requests
- Gorilla Mux requires explicit OPTIONS method registration for CORS preflight
- CORS middleware now properly handles preflight requests
All integration and unit tests now pass.
* fix: align Go version to 1.23 for CI compatibility and ensure CORS test passes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant