{"record":{"id":"96d152dc2daccc7c","repo":"gastownhall/beads","slug":"getstatistics-w","errorCode":null,"errorMessage":"GetStatistics: %w","messagePattern":"GetStatistics: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/issue.go","lineNumber":1825,"sourceCode":"\t\t\treturn ClaimReadyResult{}, fmt.Errorf(\"ClaimReadyWisp: %w\", err)\n\t\t}\n\t\treturn ClaimReadyResult{}, fmt.Errorf(\"ClaimReadyIssue: %w\", err)\n\t}\n\treturn ClaimReadyResult{Issue: issue, Claimed: issue != nil}, nil\n}\n\nfunc (u *issueUseCaseImpl) GetBlockedIssues(ctx context.Context, filter types.WorkFilter) ([]*types.BlockedIssue, error) {\n\tout, err := u.issueRepo.GetBlockedIssues(ctx, filter)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"GetBlockedIssues: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *issueUseCaseImpl) GetStatistics(ctx context.Context) (*types.Statistics, error) {\n\tout, err := u.issueRepo.GetStatistics(ctx)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"GetStatistics: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *issueUseCaseImpl) CountIssues(ctx context.Context, query string, filter types.IssueFilter) (int64, error) {\n\tout, err := u.issueRepo.CountIssues(ctx, query, filter)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"CountIssues: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc (u *issueUseCaseImpl) CountIssuesByGroup(ctx context.Context, filter types.IssueFilter, groupBy string) (map[string]int, error) {\n\tout, err := u.issueRepo.CountIssuesByGroup(ctx, filter, groupBy)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"CountIssuesByGroup: %w\", err)\n\t}\n\treturn out, nil","sourceCodeStart":1807,"sourceCodeEnd":1843,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/issue.go#L1807-L1843","documentation":"Pass-through wrapper from GetStatistics in the issue use-case: wraps errors from issueRepo.GetStatistics, which aggregates issue counts by status/priority across the whole database. Any failure computing these aggregates in storage surfaces as 'GetStatistics: <root cause>'.","triggerScenarios":"Calling GetStatistics(ctx) when the repository's aggregate queries fail — typically database unavailability, timeout on large datasets, or schema mismatch in aggregate views.","commonSituations":"Dashboard/status commands run against a very large issue database timing out; DB connection dropped; partial migration leaving aggregate queries referencing missing columns.","solutions":["Inspect the wrapped error after 'GetStatistics:' for the root cause","Retry on transient errors; verify database connectivity","For timeouts on huge datasets, ensure indexes/compaction are up to date","Confirm schema is fully migrated after upgrading beads"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"stats, err := uc.GetStatistics(ctx)\nif err != nil {\n    log.Warnf(\"statistics unavailable: %v\", err)\n    return nil\n}","preventionTips":["Retry transient errors; statistics is a read-only safe retry","Verify schema migrations completed after upgrades","For large databases, ensure maintenance/compaction runs to avoid aggregate timeouts","Check connectivity before scheduled dashboard refreshes"],"tags":["go","storage","error-wrapping","statistics"],"backgroundTag":"repository-query-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}