Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions codeframe/persistence/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ def count_branches_for_issue(self, *args, **kwargs):
"""Delegate to git_branches.count_branches_for_issue()."""
return self.git_branches.count_branches_for_issue(*args, **kwargs)

def get_branch_by_name_and_issues(self, *args, **kwargs):
"""Delegate to git_branches.get_branch_by_name_and_issues()."""
return self.git_branches.get_branch_by_name_and_issues(*args, **kwargs)

def create_test_result(self, *args, **kwargs):
"""Delegate to test_results.create_test_result()."""
return self.test_results.create_test_result(*args, **kwargs)
Expand Down
30 changes: 30 additions & 0 deletions codeframe/persistence/repositories/git_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,33 @@ def count_branches_for_issue(self, issue_id: int) -> int:
)
return cursor.fetchone()[0]

def get_branch_by_name_and_issues(
self, branch_name: str, issue_ids: List[int]
) -> Optional[Dict[str, Any]]:
"""Get a branch by name that belongs to one of the given issues.

Single-query lookup for performance optimization.

Args:
branch_name: Git branch name to find
issue_ids: List of issue IDs the branch must belong to

Returns:
Branch dictionary or None if not found
"""
if not issue_ids:
return None

cursor = self.conn.cursor()
placeholders = ",".join("?" * len(issue_ids))
cursor.execute(
f"""
SELECT * FROM git_branches
WHERE branch_name = ? AND issue_id IN ({placeholders})
LIMIT 1
""",
(branch_name, *issue_ids),
)
row = cursor.fetchone()
return dict(row) if row else None

Loading
Loading