Fix code review issues bd-19 through bd-23
- bd-19: Fix import zero-value field handling using JSON presence detection - bd-20: Add --strict flag for dependency import failures - bd-21: Simplify getNextID SQL query (reduce params from 4 to 2) - bd-22: Add validation/warning for malformed issue IDs - bd-23: Optimize export dependency queries (fix N+1 problem) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -210,6 +210,39 @@ func (s *SQLiteStorage) GetDependencyRecords(ctx context.Context, issueID string
|
||||
return deps, nil
|
||||
}
|
||||
|
||||
// GetAllDependencyRecords returns all dependency records grouped by issue ID
|
||||
// This is optimized for bulk export operations to avoid N+1 queries
|
||||
func (s *SQLiteStorage) GetAllDependencyRecords(ctx context.Context) (map[string][]*types.Dependency, error) {
|
||||
rows, err := s.db.QueryContext(ctx, `
|
||||
SELECT issue_id, depends_on_id, type, created_at, created_by
|
||||
FROM dependencies
|
||||
ORDER BY issue_id, created_at ASC
|
||||
`)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to get all dependency records: %w", err)
|
||||
}
|
||||
defer rows.Close()
|
||||
|
||||
// Group dependencies by issue ID
|
||||
depsMap := make(map[string][]*types.Dependency)
|
||||
for rows.Next() {
|
||||
var dep types.Dependency
|
||||
err := rows.Scan(
|
||||
&dep.IssueID,
|
||||
&dep.DependsOnID,
|
||||
&dep.Type,
|
||||
&dep.CreatedAt,
|
||||
&dep.CreatedBy,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to scan dependency: %w", err)
|
||||
}
|
||||
depsMap[dep.IssueID] = append(depsMap[dep.IssueID], &dep)
|
||||
}
|
||||
|
||||
return depsMap, nil
|
||||
}
|
||||
|
||||
// GetDependencyTree returns the full dependency tree
|
||||
func (s *SQLiteStorage) GetDependencyTree(ctx context.Context, issueID string, maxDepth int) ([]*types.TreeNode, error) {
|
||||
if maxDepth <= 0 {
|
||||
|
||||
Reference in New Issue
Block a user