perf(list): optimize bd list --json to fetch only needed dependencies (#1316)
Add GetDependencyRecordsForIssues method to storage interface that fetches dependencies only for specified issue IDs instead of all dependencies in the database. This optimizes bd list --json which previously called GetAllDependencyRecords() even when displaying only a few issues (e.g., bd list --limit 10). - Add GetDependencyRecordsForIssues to Storage interface - Implement in SQLite, Dolt, and Memory backends - Update list.go JSON output to use targeted method - Update mock storage in tests Origin: Mayor's review of PR #1296 Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -875,6 +875,20 @@ func (m *MemoryStorage) GetAllDependencyRecords(ctx context.Context) (map[string
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetDependencyRecordsForIssues returns dependency records for specific issues
|
||||
func (m *MemoryStorage) GetDependencyRecordsForIssues(ctx context.Context, issueIDs []string) (map[string][]*types.Dependency, error) {
|
||||
m.mu.RLock()
|
||||
defer m.mu.RUnlock()
|
||||
|
||||
result := make(map[string][]*types.Dependency)
|
||||
for _, id := range issueIDs {
|
||||
if deps, ok := m.dependencies[id]; ok {
|
||||
result[id] = deps
|
||||
}
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// GetDirtyIssueHash returns the hash for dirty issue tracking
|
||||
func (m *MemoryStorage) GetDirtyIssueHash(ctx context.Context, issueID string) (string, error) {
|
||||
// Memory storage doesn't track dirty hashes, return empty string
|
||||
|
||||
Reference in New Issue
Block a user