-
Notifications
You must be signed in to change notification settings - Fork 32
Fix undefined subcontrols #1321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
WalkthroughThe changes refactor the Changes
Sequence Diagram(s)sequenceDiagram
participant UI as ControlsTable
participant API as API Server
participant DB as Database
UI->>API: Fetch controls by category ID
API->>DB: Query controls list
DB-->>API: Return controls
loop For each control
UI->>API: Fetch subcontrol counts for control ID
API->>DB: Query subcontrol count and done count
DB-->>API: Return subcontrol counts
API-->>UI: Return subcontrol counts
UI->>UI: Attach subcontrol counts to control
end
UI->>UI: Render ControlsTable with enriched controls
Assessment against linked issues
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (2)
🚧 Files skipped from review as they are similar to previous changes (2)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@HarshP4585 - Thank you Harsh! This is working now. |
let _response = [] | ||
for (let control of response) { | ||
const subControlsResponse = await getEntityById({ | ||
routeUrl: `eu-ai-act/controlById?controlId=${control.id}&projectFrameworkId=${projectFrameworkId}`, | ||
}); | ||
_response.push({...subControlsResponse.data, ...control}); | ||
} | ||
setControls(_response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a few issues to address here. First, we are making multiple asynchronous requests inside a for loop, which results in sequential execution. This means that the next fetch will not start until the previous one has completed, significantly slowing down performance.
To improve this, we should create a specific endpoint that retrieves all the data from the controls and subcontrols in a single call.
Additionally, it would be beneficial to move the logic for calling the API to a dedicated hook, which we can name useControls
.
Describe your changes
Write your issue number after "Fixes "
Fixes #1320
Please ensure all items are checked off before requesting a review:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor