[Customer Portal[BE] Add change request stats endpoint - #278
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review infoConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds a project-level change-request statistics endpoint, supporting entity function, response mapping, and new response types; also corrects a typo in the conversation state configurable type name. (47 words) Changes
Sequence DiagramsequenceDiagram
participant Client as Client
participant Service as Service (HTTP Resource)
participant Entity as Entity Module
participant Mapper as Utils (Mapper)
Client->>Service: GET /projects/[id]/stats/change-requests
Service->>Service: Authenticate & authorize request
Service->>Entity: getProjectChangeRequestStats(idToken, projectId)
Entity->>Entity: HTTP GET /projects/[projectId]/change-requests/stats
Entity-->>Service: ProjectChangeRequestStatsResponse
Service->>Mapper: mapProjectChangeRequestStatsResponse(response)
Mapper-->>Service: types:ProjectChangeRequestStatsResponse
Service-->>Client: JSON response (totalCount, stateCount)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/customer-portal/backend/service.bal`:
- Around line 3145-3146: The resource function signature using the unconstrained
path param `[string id]` (resource function get projects/[string
id]/stats/change-requests) allows malformed IDs to reach downstream entity calls
and be collapsed into 500s; change the path parameter type to the constrained
entity:IdString (or another project ID-specific constrained type) so invalid IDs
are rejected before entity lookup, and add explicit handling to return 400 for
malformed IDs (or map non-401/403 validation failures to http:BadRequest) around
the same block that currently returns 500 (the error handling logic referenced
near lines 3177 and the similar code in the 3157–3184 region). Ensure you update
the function signature and the corresponding validation/error branch so client
errors become 400 responses instead of 500.
ℹ️ Review info
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
apps/customer-portal/backend/modules/entity/entity.balapps/customer-portal/backend/modules/entity/types.balapps/customer-portal/backend/modules/entity/utils.balapps/customer-portal/backend/modules/types/types.balapps/customer-portal/backend/service.balapps/customer-portal/backend/utils.bal
788d5f8
into
wso2-open-operations:customer-portal-milestone-1
Description
This PR introduces a new endpoint to provide statistical data for change requests.
Changes
Functionality
The new endpoint provides aggregated statistics such as:
Reason
Change request reporting required a dedicated endpoint to:
Centralizing this logic in the backend ensures scalable and reliable reporting.
Testing
Impact
Related PRs
Summary by CodeRabbit
New Features
Bug Fixes