refactor: simplify connection retrieval in GetHostedConnectionCredentialsUseCase#1734
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Pull request overview
Refactors the SaaS microservice use case that retrieves hosted database connection credentials by switching to a repository helper method for fetching the connection entity.
Changes:
- Replaced a generic
findOne({ where: { id } })lookup withconnectionRepository.findOneConnection(hostedDatabaseId)inGetHostedConnectionCredentialsUseCase.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const connection = await this._dbContext.connectionRepository.findOne({ | ||
| where: { id: inputData.hostedDatabaseId }, | ||
| }); | ||
| const connection = await this._dbContext.connectionRepository.findOneConnection(inputData.hostedDatabaseId); |
There was a problem hiding this comment.
findOneConnection() has side effects (it generates signing_key when missing and persists the entity) and also loads connection_properties. For a credentials-read use case this introduces an unexpected write + extra join overhead. Prefer using connectionRepository.findOneById(hostedDatabaseId) (it decrypts credentials without mutating) or a dedicated read-only method without the signing_key backfill.
| const connection = await this._dbContext.connectionRepository.findOneConnection(inputData.hostedDatabaseId); | |
| const connection = await this._dbContext.connectionRepository.findOneById(inputData.hostedDatabaseId); |
Summary by CodeRabbit