Skip to content

Conversation

ryanaidilp
Copy link
Contributor

@ryanaidilp ryanaidilp commented Sep 7, 2025

Summary

  • Group ODP (Person Under Observation) and PDP (Patient Under Supervision) data into structured objects
  • Add new endpoint to get provinces with their latest case data
  • Improve API response structure for better data organization

Changes Made

1. ODP/PDP Data Grouping

  • Created ObservationData and SupervisionData structs to group related fields
  • Updated ProvinceDailyCases to use grouped ODP/PDP structures with keys:
    • daily.odp.active, daily.odp.finished, daily.odp.total
    • daily.pdp.active, daily.pdp.finished, daily.pdp.total
  • Updated ProvinceCumulativeCases with similar grouped structure for cumulative data
  • Maintained backward compatibility with data calculations

2. Provinces with Latest Case Data

  • Added ProvinceWithLatestCase model to combine province info with latest case data
  • Added GetProvincesWithLatestCase() service method
  • Updated /api/v1/provinces endpoint to support ?include_latest_case=true query parameter
  • When enabled, returns provinces with their latest COVID-19 case data

3. Testing

  • Updated all test cases to use new grouped ODP/PDP structure
  • Added mock service method for new endpoint
  • All tests passing successfully

API Usage Examples

Get provinces with latest case data:

GET /api/v1/provinces

Province case response now has grouped ODP/PDP:

{
  "daily": {
    "positive": 100,
    "recovered": 80,
    "deceased": 5,
    "active": 15,
    "odp": {
      "active": 5,
      "finished": 10,
      "total": 15
    },
    "pdp": {
      "active": 5,
      "finished": 15,
      "total": 20
    }
  }
}

Test Results

  • ✅ All unit tests passing
  • ✅ All integration tests passing
  • ✅ No regressions in existing functionality

- Add ObservationData and SupervisionData structs
- Group ODP fields under 'odp' key with active, finished, total
- Group PDP fields under 'pdp' key with active, finished, total
- Maintain backward compatibility with data calculation
- Add ProvinceWithLatestCase model
- Add GetProvincesWithLatestCase service method
- Update GetProvinces endpoint to support include_latest_case query param
- Fetch and include latest case data for each province when requested
- Update test expectations to use ObservationData and SupervisionData structs
- Fix all test cases to match new nested ODP/PDP structure
- Ensure all tests pass with grouped ODP/PDP fields
- Add GetProvincesWithLatestCase to mock service
- Update health check test to expect version 2.0.2
- Ensure all handler tests pass
@ryanaidilp ryanaidilp self-assigned this Sep 7, 2025
- Create separate DailyObservationData and DailySupervisionData structs
- Daily data only includes active and finished (no total)
- Cumulative data includes active, finished, and total
- Update all test cases to match corrected structure
- All tests passing
- Add pagination models with metadata support
- Add query parameter parsing utilities
- Implement paginated repository methods
- Add paginated service layer methods
- Update handlers to support hybrid pagination:
  - ?all=true: Returns complete dataset (for charts/analytics)
  - Default: Returns paginated data (limit=50, max=1000)
  - ?limit=N&offset=M: Custom pagination
  - Works with date ranges and province filtering
- Maintain backward compatibility with existing endpoints
- Add detailed API_DOCUMENTATION.md with endpoint specs
- Update README with new pagination features and usage examples
- Document enhanced ODP/PDP data structure
- Add practical usage examples for different use cases
- Include response format specifications and best practices
- Change default behavior to include COVID-19 case data for better UX
- Add exclude_latest_case parameter for basic province list only
- Update all tests to reflect new default behavior
- Update API documentation and README with new usage patterns
- Maintain backward compatibility with existing parameter

This change makes the COVID-19 API more intuitive by showing current
pandemic status by default, which is what users typically expect.
- Generate interactive Swagger UI accessible at /swagger/index.html
- Add detailed Go annotations for all API endpoints with parameters, responses
- Include comprehensive OpenAPI 3.0 specification (YAML/JSON)
- Auto-document all models including enhanced ODP/PDP structure
- Support for pagination metadata and hybrid response types
- Add redirect from root to swagger docs for convenience
- Include documentation regeneration instructions for developers

Key improvements:
- Complete API specification with examples
- Type-safe client code generation support
- Interactive testing interface
- Automatic validation of API contracts
- Professional API documentation presentation
- Update API title to 'Sulawesi Tengah COVID-19 Data API'
- Clarify that national and other provincial data are for context
- Emphasize primary focus on Central Sulawesi COVID-19 data
- Update all documentation files (README, API docs, Swagger specs)
- Regenerate OpenAPI documentation with correct regional focus

This better reflects the actual purpose and scope of the API,
making it clear to users that while national data is available,
the main focus is on Sulawesi Tengah regional COVID-19 information.
- Add LICENSE file with MIT license terms
- Update README to reference LICENSE file
- Include copyright notice for Banua Coder
- Ensures proper open source licensing for the project

The MIT license allows free use, modification, and distribution
while providing liability protection for the authors.
- Remove API_DOCUMENTATION.md (replaced by auto-generated Swagger docs)
- Update README project structure to reflect current directories
- Add descriptions for docs/, pkg/utils/, test/, and other directories
- Highlight auto-generated documentation approach

The OpenAPI/Swagger documentation provides comprehensive API docs
that are always up-to-date with the code, making manual documentation
files redundant.
- Add GetAPIIndex handler to return comprehensive endpoint information
- Include API metadata, documentation links, and feature descriptions
- Support both /api/v1 and /api/v1/ routes for better UX
- Add comprehensive test coverage for the new endpoint
- Update Swagger documentation with new endpoint specification
- Enhance API discoverability with structured endpoint listing
@ryanaidilp ryanaidilp force-pushed the feature/province-odp-pdp-grouping branch from 75622b5 to ea4308c Compare September 7, 2025 17:45
@ryanaidilp ryanaidilp merged commit 3147adc into develop Sep 7, 2025
2 checks passed
@ryanaidilp ryanaidilp deleted the feature/province-odp-pdp-grouping branch September 7, 2025 18:03
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