Skip to content

perf: get entity by id#837

Merged
adityachoudhari26 merged 1 commit intomainfrom
get-entity-by-id
Mar 6, 2026
Merged

perf: get entity by id#837
adityachoudhari26 merged 1 commit intomainfrom
get-entity-by-id

Conversation

@adityachoudhari26
Copy link
Member

@adityachoudhari26 adityachoudhari26 commented Mar 6, 2026

Summary by CodeRabbit

  • Refactor
    • Optimized entity retrieval logic by introducing a direct lookup method across variable resolution components, replacing the previous approach of loading all candidates and filtering to a specific ID.
    • Updated error handling for entity retrieval operations.
    • Extended test infrastructure to support the new lookup functionality.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 6, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: bcdcd5ad-869b-41fd-b4b9-60732a2f8c80

📥 Commits

Reviewing files that changed from the base of the PR and between 7bca65e and b4dacbe.

📒 Files selected for processing (6)
  • apps/workspace-engine/svc/controllers/desiredrelease/adapters.go
  • apps/workspace-engine/svc/controllers/desiredrelease/getters.go
  • apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres.go
  • apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/resolve.go
  • apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/resolve_test.go
  • apps/workspace-engine/test/controllers/harness/mocks.go

📝 Walkthrough

Walkthrough

The changes add a new GetEntityByID method across the desiredrelease package to enable direct entity retrieval by ID and type, replacing the previous pattern of loading all candidates and filtering through them in the variable resolver.

Changes

Cohort / File(s) Summary
Interface and Adapter Layer
apps/workspace-engine/svc/controllers/desiredrelease/getters.go, apps/workspace-engine/svc/controllers/desiredrelease/adapters.go
Added GetEntityByID method to the Getter interface; adapter delegates to underlying getter implementation.
PostgreSQL Implementation
apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres.go
Implemented GetEntityByID with type-specific SQL queries for resources, deployments, and environments; includes ID parsing, error handling for unknown types and missing rows, and EntityData construction.
Resolver Integration
apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/resolve.go
Refactored ResolveRelated to call GetEntityByID directly instead of loading all candidates and filtering by ID; updated error messages and entity conversion logic.
Test Helpers
apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/resolve_test.go, apps/workspace-engine/test/controllers/harness/mocks.go
Added mock implementations of GetEntityByID for resolver and harness test utilities; includes candidate lookup by ID with appropriate error reporting.

Suggested reviewers

  • jsbroks

Poem

🐰 A getter swift and true,
By ID it fetches you,
No candidates to sort and sift,
Direct retrieval is our gift!
Entities jump through with glee,
Faster now, more spry are we!

Estimated code review effort: 🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introducing a GetEntityByID method for direct entity retrieval by ID, which optimizes performance by eliminating candidate filtering loops.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch get-entity-by-id

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.

@adityachoudhari26 adityachoudhari26 merged commit 6175e11 into main Mar 6, 2026
6 of 9 checks passed
@adityachoudhari26 adityachoudhari26 deleted the get-entity-by-id branch March 6, 2026 22:49
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