Skip to content

[Customer Portal[BE] Refactor case response, update conversation search payload, and rename project activity stats field - #273

Merged
sacheeramesh merged 1 commit into
wso2-open-operations:customer-portal-milestone-1from
Rashmika998:customer-portal-milestone-1-projects
Mar 1, 2026
Merged

sacheeramesh merged 1 commit into
wso2-open-operations:customer-portal-milestone-1from
Rashmika998:customer-portal-milestone-1-projects

Conversation

@Rashmika998

@Rashmika998 Rashmika998 commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Description

This PR includes the following updates:

  1. Refactored case response to support service request–related fields
  2. Updated conversation search payload to fetch conversations created by the logged-in user
  3. Renamed project activity stats response field from totalTimeLogged to totalHours

Changes

1️⃣ Case Response Refactor

  • Extended case response model to include service request–related fields:
    • catalogs
    • catalog items
    • createdBy
  • Updated DTOs and mappings
  • Adjusted serialization logic
  • Ensured compatibility with service request workflows

Reason:
Cases now support service request–based data, and the response structure needed to reflect related catalog information to support UI and downstream integrations.


2️⃣ Conversation Search Payload Update

  • Updated conversation search payload logic
  • Filtered conversations to return only those created by the logged-in user
  • Integrated user context from authentication token
  • Improved validation and filtering logic

Reason:
Ensures users only retrieve their own conversations, improving security and data isolation.


3️⃣ Project Activity Stats Field Rename

  • Renamed response field:
    • FROM: totalTimeLogged
    • TO: totalHours
  • Updated response model and related mappings

Reason:
The new field name better reflects the actual unit and improves clarity in reporting and dashboard usage.


Impact

⚠ Case response structure extended (may require frontend adjustment)
⚠ Field rename (totalTimeLoggedtotalHours) may be a breaking change

  • Conversation filtering behavior updated to be user-specific

Testing

  • Verified case response includes service request fields
  • Tested conversation search for logged-in user filtering
  • Confirmed project activity stats returns totalHours

Related PRs

Summary by CodeRabbit

Release Notes

  • New Features

    • Service case records now display creator information and associated catalog metadata for enhanced traceability.
    • Conversation search expanded with a filter to display conversations created by the current user.
  • Improvements

    • Project statistics now report "Total Hours" for clearer time tracking metrics.

@coderabbitai

coderabbitai Bot commented Mar 1, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

The changes extend the Case data structure with creator and catalog metadata fields, rename the time-logging field from totalTimeLogged to totalHours in project stats responses, and add a createdByMe filter to conversation search capabilities across multiple backend files.

Changes

Cohort / File(s) Summary
Type Definitions
apps/customer-portal/backend/modules/entity/types.bal, apps/customer-portal/backend/modules/types/types.bal
Added createdBy (string), catalog (ReferenceTableItem?), and catalogItem (ReferenceTableItem?) fields to Case. Renamed ProjectStatsResponse/RecentActivity field from totalTimeLogged? to totalHours? (decimal). Extended ConversationSearchPayload.filters with createdByMe? (boolean) filter.
Service Layer
apps/customer-portal/backend/service.bal
Updated project stats endpoint to return recentActivity.totalHours instead of totalTimeLogged. Updated conversations search endpoint to accept createdByMe filter in payload.filters.
Utility Mappings
apps/customer-portal/backend/utils.bal
Updated case search and response mapping functions to populate new createdBy, catalog, and catalogItem fields in CaseSearchResponse and CaseResponse objects.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • shayanmalinda
  • cloby99
  • sacheeramesh

Poem

🐰 Hoppity hop, the Case now grows,
createdBy and catalog flows,
Hours ticked, no longer logged,
Conversations filtered, filters slogged,
Metadata blooms where fields reside!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description covers the key changes with clear sections, rationale, and impact. However, it deviates significantly from the required template, missing sections like Purpose (with issue links), User stories, Release notes, Documentation, Training, Certification, Marketing, Automation tests, Security checks, Samples, Migrations, Test environment, and Learning. Restructure the description to follow the repository template, adding missing sections such as Purpose with issue links, User stories, Release notes, Documentation links, and details on automation tests and security checks performed.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title directly summarizes the three main changes: case response refactor, conversation search payload update, and project activity stats field rename.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@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/service.bal (1)

1093-1100: ⚠️ Potential issue | 🟠 Major

Enforce creator-only conversation filtering server-side.

Line 1099 passes createdByMe from client input. A client can omit or set it to false, which can bypass the “created by logged-in user only” behavior.

🔧 Proposed fix
         entity:ConversationSearchResponse|error conversationResponse = entity:searchConversations(userInfo.idToken,
                 {
                     filters: {
                         projectIds: [id],
                         stateKeys: payload.filters?.stateKeys,
                         searchQuery: payload.filters?.searchQuery,
-                        createdByMe: payload.filters?.createdByMe
+                        createdByMe: true
                     },
                     sortBy: payload.sortBy,
                     pagination: payload.pagination
                 });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/customer-portal/backend/service.bal` around lines 1093 - 1100, The call
to entity:searchConversations currently passes the client-supplied
payload.filters?.createdByMe which allows a client to bypass creator-only
filtering; override that value server-side by replacing
payload.filters?.createdByMe with a server-determined boolean (e.g., true when
this endpoint must restrict results to the logged-in user) before calling
entity:searchConversations (the call using userInfo.idToken and the filters
object), ensuring the createdByMe flag cannot be controlled by client input.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@apps/customer-portal/backend/service.bal`:
- Around line 1093-1100: The call to entity:searchConversations currently passes
the client-supplied payload.filters?.createdByMe which allows a client to bypass
creator-only filtering; override that value server-side by replacing
payload.filters?.createdByMe with a server-determined boolean (e.g., true when
this endpoint must restrict results to the logged-in user) before calling
entity:searchConversations (the call using userInfo.idToken and the filters
object), ensuring the createdByMe flag cannot be controlled by client input.

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f10f1b5 and 73fddbc.

📒 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/service.bal
  • apps/customer-portal/backend/utils.bal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

App/Customer Portal Area/Backend Type/Improvement Marks enhancements or improvements to existing features

Projects

Status: Staging Deployed

Development

Successfully merging this pull request may close these issues.

2 participants