-
Notifications
You must be signed in to change notification settings - Fork 728
feat: refactor integration api (CM-809) #3748
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: main
Are you sure you want to change the base?
Conversation
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.
Pull request overview
This PR refactors two repository methods (findGlobalIntegrations and findGlobalIntegrationsStatusCount) to improve code structure and performance. The refactoring wraps parameters in a filters object for better organization and implements parallel query execution using Promise.all() to reduce overall execution time.
Changes:
- Restructured function parameters to use a
filtersobject instead of direct destructuring - Implemented parallel execution of data fetching and count queries in both methods
- Improved consistency in count result handling with fallback values
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ]) | ||
|
|
||
| // Both functions return an array with count objects, so we take the first element | ||
| const count = (countResult as { count: number }[])[0]?.count |
Copilot
AI
Jan 14, 2026
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.
The type cast here assumes countResult is always an array, but the destructuring pattern differs from the findGlobalIntegrationsStatusCount method (line 392) which uses [notConnectedResult] to explicitly destructure the first element. For consistency and clarity, consider destructuring countResult directly in the Promise.all statement as [rows, [countObj]] and accessing countObj.count without the type cast.
| return [...rows, { status: 'not-connected', count: +result.count }] | ||
|
|
||
| // Execute both queries in parallel for better performance | ||
| const [statusCounts, [notConnectedResult]] = await Promise.all([ |
Copilot
AI
Jan 14, 2026
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.
The destructuring pattern [notConnectedResult] assumes the function always returns a non-empty array. If fetchGlobalNotConnectedIntegrationsCount could potentially return an empty array, accessing notConnectedResult.count on line 401 would fail. Consider adding a fallback or validating the array is not empty before destructuring, similar to the optional chaining used in line 361.
Refactored findGlobalIntegrationsStatusCount and findGlobalIntegrations
These two functions were refactored to improve clarity and maintainability.
The new structure allows them to be executed in parallel, reducing overall execution time and improving performance.
Note
Improves performance and API consistency for global integrations queries.
findGlobalIntegrationsto accept afiltersobject, normalizestatus, detectnot-connected, and run fetch + count viaPromise.all; returns{ rows, count, limit, offset }with safe numeric coercionfindGlobalIntegrationsStatusCountto accept afiltersobject and perform status counts andnot-connectedcount in parallel, merging results into a single arrayintegrationRepository.tswithout changing external behavior beyond the newfiltersparameterWritten by Cursor Bugbot for commit 2313879. This will update automatically on new commits. Configure here.