Gate embeddeddolt package on //go:build cgo with stub files for !cgo. Android and freebsd targets use CGO_ENABLED=0 since zig lacks sysroot headers for these platforms. Server mode still works on all targets. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
36 lines
845 B
Go
36 lines
845 B
Go
//go:build cgo
|
|
|
|
package embeddeddolt
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"fmt"
|
|
|
|
"github.com/steveyegge/beads/internal/storage/issueops"
|
|
"github.com/steveyegge/beads/internal/types"
|
|
)
|
|
|
|
func (s *EmbeddedDoltStore) GetStatistics(ctx context.Context) (*types.Statistics, error) {
|
|
stats := &types.Statistics{}
|
|
err := s.withConn(ctx, false, func(tx *sql.Tx) error {
|
|
if err := issueops.ScanIssueCountsInTx(ctx, tx, stats); err != nil {
|
|
return err
|
|
}
|
|
|
|
blockedIDs, _, err := issueops.ComputeBlockedIDsInTx(ctx, tx, true)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
stats.BlockedIssues = len(blockedIDs)
|
|
stats.ReadyIssues = stats.OpenIssues - stats.BlockedIssues
|
|
if stats.ReadyIssues < 0 {
|
|
stats.ReadyIssues = 0
|
|
}
|
|
return nil
|
|
})
|
|
if err != nil {
|
|
return nil, fmt.Errorf("embeddeddolt: get statistics: %w", err)
|
|
}
|
|
return stats, nil
|
|
}
|