Skip to content

[Customer Portal Backend] Add productCount to deployments search response - #1040

Merged
cloby99 merged 1 commit into
wso2-open-operations:mainfrom
cloby99:feat/pct
Jul 4, 2026
Merged

cloby99 merged 1 commit into
wso2-open-operations:mainfrom
cloby99:feat/pct

Conversation

@cloby99

@cloby99 cloby99 commented Jul 4, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Added productCount field to the Deployment response type, mapped from deployedProductCount returned by the entity service
  • Updated mapDeployments() in utils.bal to pass through the new field
  • Updated openapi.yaml with Deployment and DeploymentsResponse schemas including productCount, and wired the 200 response for POST /projects/{id}/deployments/search

Test plan

  • Call POST /projects/{id}/deployments/search and verify each deployment object includes productCount
  • Verify productCount is absent (not null) when entity service does not return deployedProductCount

Summary by CodeRabbit

  • New Features

    • Deployment search results now return richer deployment details, including the number of deployed products.
    • API responses for deployment searches now include a defined paginated response structure.
  • Bug Fixes

    • Deployment data returned to the customer portal now consistently includes the new product count field when available.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds an optional productCount field for deployments across the customer-portal backend: deployedProductCount in the entity Deployment record, productCount in the service Deployment record, corresponding OpenAPI schema definitions (Deployment, DeploymentsResponse) with a new JSON response for the deployments search endpoint, and mapping logic in mapDeployments to populate the new field.

Changes

Deployment product count

Layer / File(s) Summary
Type definitions
apps/customer-portal/backend/modules/entity/types.bal, apps/customer-portal/backend/modules/types/types.bal
Adds optional deployedProductCount to entity Deployment and optional productCount to service Deployment.
OpenAPI schema and response
apps/customer-portal/backend/openapi.yaml
Adds application/json schema reference for the deployments search 200 response and defines Deployment/DeploymentsResponse schemas including productCount and pagination fields.
Mapping logic
apps/customer-portal/backend/utils.bal
Updates mapDeployments to populate productCount from deployedProductCount.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested labels: Type/Improvement

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and test plan only; it misses most required template sections like Purpose, Goals, Approach, docs, tests, and security. Add the missing template sections, especially Purpose, Goals, Approach, Release note, Documentation, Automation tests, Security checks, and Test environment.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding productCount to the deployments search response.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/customer-portal/backend/utils.bal (1)

325-341: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Use optional field access for deployedProductCount. deployment.deployedProductCount can panic when the entity service omits the field; switch to deployment?.deployedProductCount so productCount stays empty instead of failing the mapping.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/customer-portal/backend/utils.bal` around lines 325 - 341, The
mapDeployments transformation currently reads deployment.deployedProductCount
directly, which can panic when the field is omitted. Update the Deployment
mapping in mapDeployments to use optional field access for deployedProductCount
so productCount becomes empty instead of failing, while keeping the rest of the
response mapping unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@apps/customer-portal/backend/utils.bal`:
- Around line 325-341: The mapDeployments transformation currently reads
deployment.deployedProductCount directly, which can panic when the field is
omitted. Update the Deployment mapping in mapDeployments to use optional field
access for deployedProductCount so productCount becomes empty instead of
failing, while keeping the rest of the response mapping unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 2a74c629-81ef-4a1c-bf3d-0ec8451cb19c

📥 Commits

Reviewing files that changed from the base of the PR and between 3faabd6 and 8b92b8f.

📒 Files selected for processing (4)
  • apps/customer-portal/backend/modules/entity/types.bal
  • apps/customer-portal/backend/modules/types/types.bal
  • apps/customer-portal/backend/openapi.yaml
  • apps/customer-portal/backend/utils.bal

@cloby99
cloby99 requested a review from Rashmika998 July 4, 2026 08:59
@cloby99
cloby99 merged commit a681c14 into wso2-open-operations:main Jul 4, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants