Skip to content

Improve Subscribe APIs dialog loading performance - #1410

Open
nisan-abeywickrama wants to merge 5 commits into
wso2:mainfrom
nisan-abeywickrama:fix/subscribe-dialog-perf
Open

Improve Subscribe APIs dialog loading performance#1410
nisan-abeywickrama wants to merge 5 commits into
wso2:mainfrom
nisan-abeywickrama:fix/subscribe-dialog-perf

Conversation

@nisan-abeywickrama

Copy link
Copy Markdown
Contributor

Description

The "Subscribe APIs" dialog lists APIs 10 per page, but it loaded the application's entire subscription list up front just to mark which ones were already subscribed. For an application with 270 subscriptions the dialog blocked on a spinner for over 3 minutes.

Approach

Subscriptions.jsx no longer calls loadAllSubscriptions for the dialog. APICardView now resolves subscription status only for the APIs on the current page, calling the subscriptions API with both apiId and applicationId so each lookup returns at most one record. A refreshKey prop replaces the subscription list as the reload trigger, used on dialog open and after a successful subscribe.

Related Issue

wso2/api-manager#5148

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

APICardView now resolves subscription status per listed entity through Subscription API calls. Subscribe dialogs use independent refresh keys to reload API and MCP listings without loading complete subscription collections.

Changes

Subscription refresh flow

Layer / File(s) Summary
Per-entity subscription resolution
portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICardView.jsx, portals/devportal/src/main/webapp/source/src/app/data/Subscription.jsx
APICardView resolves subscription IDs for each listed entity and application. Subscription.getSubscriptions supports optional match filtering. The view uses Set membership checks, request sequencing, and refreshKey-based reloads.
Dialog refresh wiring
portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/Subscriptions.jsx
API and MCP dialogs use separate refresh keys. Dialogs pass refresh keys to APIList instead of subscription collections.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Subscriptions
  participant APIList
  participant APICardView
  participant Subscription
  Subscriptions->>Subscriptions: increment API or MCP refreshKey
  Subscriptions->>APIList: pass refreshKey
  APIList->>APICardView: reload listing
  APICardView->>Subscription: query subscription status per entity
  Subscription-->>APICardView: return subscription results
  APICardView->>APICardView: filter displayed entities
Loading

Suggested reviewers: heshansudarshana, hisanhunais, pasant9

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: improved loading performance for the Subscribe APIs dialog.
Description check ✅ Passed The description directly explains the performance problem and the implementation changes in the pull request.
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.

Actionable comments posted: 2

🤖 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.

Inline comments:
In
`@portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICardView.jsx`:
- Around line 143-151: Update the subscription lookup flow in
updateUnsubscribedAPIsList so getSubscriptions failures are not swallowed by the
empty catch. Propagate the rejection to the existing page-load error handler, or
preserve the entity as an unknown status and disable subscription actions for
that APICardView instead of treating it as unsubscribed.
- Around line 105-107: Update the asynchronous load flows in getData and
changePage to share one monotonically increasing load ID for every request.
Capture each request’s ID and, before updating data, showing errors, or clearing
loading, confirm it is still the current ID so stale refresh, search, or page
results cannot overwrite the active page.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: f71803b6-5d21-4183-ad0b-dc414f36dbb6

📥 Commits

Reviewing files that changed from the base of the PR and between 935e773 and 57ad32d.

📒 Files selected for processing (2)
  • portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICardView.jsx
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/Subscriptions.jsx

@nisan-abeywickrama

Copy link
Copy Markdown
Contributor Author

@coderabbitai full review

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@nisan-abeywickrama

Copy link
Copy Markdown
Contributor Author

@CodeRabbit full review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.


Your included review limit is currently reached under our Fair Usage Limits Policy. This review may still proceed through usage-based billing if eligible. Your next included review will be available in 16 minutes.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 6, 2026
@nisan-abeywickrama

Copy link
Copy Markdown
Contributor Author

@CodeRabbit full review

@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor
✅ Action performed

Full review finished.

@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.

Actionable comments posted: 1

🤖 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.

Inline comments:
In
`@portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICardView.jsx`:
- Around line 101-102: Update the reload flow in the method containing
apiLoadRequestId so it sets loading to true immediately after allocating
requestId and before starting xhrRequest(). Preserve the existing finally
behavior that clears loading only for the current request.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a2080ac-351f-4c3a-a6a6-b5dea600f1ba

📥 Commits

Reviewing files that changed from the base of the PR and between 935e773 and 0c7514f.

📒 Files selected for processing (3)
  • portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICardView.jsx
  • portals/devportal/src/main/webapp/source/src/app/components/Applications/Details/Subscriptions.jsx
  • portals/devportal/src/main/webapp/source/src/app/data/Subscription.jsx

Comment on lines +101 to 102
const requestId = ++this.apiLoadRequestId;
this.xhrRequest()

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Set loading before starting every reload.

When refreshKey changes after a successful subscription, this method keeps the previous data visible until all status lookups finish. The old SubscriptionPolicySelect remains actionable during that interval. A user can submit a second subscription request for the same API.

Set loading: true immediately after allocating requestId. The existing finally block will clear it only for the current request.

Proposed fix
 const requestId = ++this.apiLoadRequestId;
+this.setState({ loading: true });
 this.xhrRequest()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const requestId = ++this.apiLoadRequestId;
this.xhrRequest()
const requestId = ++this.apiLoadRequestId;
this.setState({ loading: true });
this.xhrRequest()
🤖 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
`@portals/devportal/src/main/webapp/source/src/app/components/Apis/Listing/APICardView.jsx`
around lines 101 - 102, Update the reload flow in the method containing
apiLoadRequestId so it sets loading to true immediately after allocating
requestId and before starting xhrRequest(). Preserve the existing finally
behavior that clears loading only for the current request.

@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

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