Skip to content

refactor: simplify connection retrieval in GetHostedConnectionCredentialsUseCase#1734

Merged
Artuomka merged 1 commit into
mainfrom
backend_pg_proxy
Apr 24, 2026
Merged

refactor: simplify connection retrieval in GetHostedConnectionCredentialsUseCase#1734
Artuomka merged 1 commit into
mainfrom
backend_pg_proxy

Conversation

@Artuomka
Copy link
Copy Markdown
Collaborator

@Artuomka Artuomka commented Apr 24, 2026

Summary by CodeRabbit

  • Refactor
    • Optimized the database retrieval method for fetching hosted connection credentials to improve code efficiency. No functional changes to user-facing behavior.

Copilot AI review requested due to automatic review settings April 24, 2026 12:21
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 24, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55bf4e97-0470-4944-a62a-43ccc6e37ce1

📥 Commits

Reviewing files that changed from the base of the PR and between b76b232 and a2f428d.

📒 Files selected for processing (1)
  • backend/src/microservices/saas-microservice/use-cases/get-hosted-connection-credentials.use.case.ts

📝 Walkthrough

Walkthrough

The GetHostedConnectionCredentialsUseCase implementation was updated to use a more specific repository method findOneConnection instead of a generic findOne call with filter parameters. The exception handling and response mapping remain unchanged.

Changes

Cohort / File(s) Summary
Repository Method Refactoring
backend/src/microservices/saas-microservice/use-cases/get-hosted-connection-credentials.use.case.ts
Replaced generic findOne({ where: { id } }) database retrieval with the dedicated findOneConnection() repository method, improving code clarity and consistency.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops through queries with glee,
Trading generic calls for specificity,
findOneConnection shines bright and clear,
Cleaner, more precise, no doubt here! 🐰✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch backend_pg_proxy

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.

@Artuomka Artuomka merged commit 36d3ad8 into main Apr 24, 2026
15 of 18 checks passed
@Artuomka Artuomka deleted the backend_pg_proxy branch April 24, 2026 12:21
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with connectionRepository.findOneConnection(hostedDatabaseId) in GetHostedConnectionCredentialsUseCase.

💡 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);
Copy link

Copilot AI Apr 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
const connection = await this._dbContext.connectionRepository.findOneConnection(inputData.hostedDatabaseId);
const connection = await this._dbContext.connectionRepository.findOneById(inputData.hostedDatabaseId);

Copilot uses AI. Check for mistakes.
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.

2 participants