store

package
v0.4.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package store opens metrics.sqlite, applies the DDL, and exposes prepared inserts for the canonical tables.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildJobsBatch added in v0.4.9

type BuildJobsBatch struct {
	// contains filtered or unexported fields
}

BuildJobsBatch buffers model.BuildJob rows.

func (*BuildJobsBatch) Add added in v0.4.9

func (b *BuildJobsBatch) Add(j model.BuildJob) error

func (*BuildJobsBatch) Commit added in v0.4.9

func (b *BuildJobsBatch) Commit() (int, error)

func (*BuildJobsBatch) Rollback added in v0.4.9

func (b *BuildJobsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type BuildsBatch added in v0.4.9

type BuildsBatch struct {
	// contains filtered or unexported fields
}

BuildsBatch buffers model.Build rows.

func (*BuildsBatch) Add added in v0.4.9

func (b *BuildsBatch) Add(bd model.Build) error

func (*BuildsBatch) Commit added in v0.4.9

func (b *BuildsBatch) Commit() (int, error)

func (*BuildsBatch) Rollback added in v0.4.9

func (b *BuildsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type CommitCoauthorsBatch added in v0.4.9

type CommitCoauthorsBatch struct {
	// contains filtered or unexported fields
}

CommitCoauthorsBatch buffers model.CommitCoauthor rows.

func (*CommitCoauthorsBatch) Add added in v0.4.9

func (*CommitCoauthorsBatch) Commit added in v0.4.9

func (b *CommitCoauthorsBatch) Commit() (int, error)

func (*CommitCoauthorsBatch) Rollback added in v0.4.9

func (b *CommitCoauthorsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type CommitFilesBatch added in v0.4.9

type CommitFilesBatch struct {
	// contains filtered or unexported fields
}

CommitFilesBatch buffers model.CommitFile rows for the commit_files table.

func (*CommitFilesBatch) Add added in v0.4.9

func (*CommitFilesBatch) Commit added in v0.4.9

func (b *CommitFilesBatch) Commit() (int, error)

func (*CommitFilesBatch) Rollback added in v0.4.9

func (b *CommitFilesBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type CommitsBatch added in v0.4.9

type CommitsBatch struct {
	// contains filtered or unexported fields
}

CommitsBatch buffers model.Commit rows for the commits table.

func (*CommitsBatch) Add added in v0.4.9

func (b *CommitsBatch) Add(c model.Commit) error

func (*CommitsBatch) Commit added in v0.4.9

func (b *CommitsBatch) Commit() (int, error)

func (*CommitsBatch) Rollback added in v0.4.9

func (b *CommitsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type FileComplexityHistoryBatch added in v0.4.9

type FileComplexityHistoryBatch struct {
	// contains filtered or unexported fields
}

FileComplexityHistoryBatch buffers model.FileComplexityHistory rows for the largest hot table.

func (*FileComplexityHistoryBatch) Add added in v0.4.9

func (*FileComplexityHistoryBatch) Commit added in v0.4.9

func (b *FileComplexityHistoryBatch) Commit() (int, error)

func (*FileComplexityHistoryBatch) Rollback added in v0.4.9

func (b *FileComplexityHistoryBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type FileMetricsBatch added in v0.4.9

type FileMetricsBatch struct {
	// contains filtered or unexported fields
}

FileMetricsBatch buffers model.FileMetric rows.

func (*FileMetricsBatch) Add added in v0.4.9

func (*FileMetricsBatch) Commit added in v0.4.9

func (b *FileMetricsBatch) Commit() (int, error)

func (*FileMetricsBatch) Rollback added in v0.4.9

func (b *FileMetricsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type PRCommentsBatch added in v0.4.9

type PRCommentsBatch struct {
	// contains filtered or unexported fields
}

PRCommentsBatch buffers model.PRComment rows.

func (*PRCommentsBatch) Add added in v0.4.9

func (*PRCommentsBatch) Commit added in v0.4.9

func (b *PRCommentsBatch) Commit() (int, error)

func (*PRCommentsBatch) Rollback added in v0.4.9

func (b *PRCommentsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type PRCommitsBatch added in v0.4.9

type PRCommitsBatch struct {
	// contains filtered or unexported fields
}

PRCommitsBatch buffers model.PRCommit rows.

func (*PRCommitsBatch) Add added in v0.4.9

func (b *PRCommitsBatch) Add(p model.PRCommit) error

func (*PRCommitsBatch) Commit added in v0.4.9

func (b *PRCommitsBatch) Commit() (int, error)

func (*PRCommitsBatch) Rollback added in v0.4.9

func (b *PRCommitsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type PRLabelsBatch added in v0.4.9

type PRLabelsBatch struct {
	// contains filtered or unexported fields
}

PRLabelsBatch buffers model.PRLabel rows.

func (*PRLabelsBatch) Add added in v0.4.9

func (b *PRLabelsBatch) Add(l model.PRLabel) error

func (*PRLabelsBatch) Commit added in v0.4.9

func (b *PRLabelsBatch) Commit() (int, error)

func (*PRLabelsBatch) Rollback added in v0.4.9

func (b *PRLabelsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type PRsBatch added in v0.4.9

type PRsBatch struct {
	// contains filtered or unexported fields
}

PRsBatch buffers model.PR rows for the prs table.

func (*PRsBatch) Add added in v0.4.9

func (b *PRsBatch) Add(p model.PR) error

func (*PRsBatch) Commit added in v0.4.9

func (b *PRsBatch) Commit() (int, error)

func (*PRsBatch) Rollback added in v0.4.9

func (b *PRsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type RepoFilesBatch added in v0.4.9

type RepoFilesBatch struct {
	// contains filtered or unexported fields
}

RepoFilesBatch buffers model.RepoFile rows.

func (*RepoFilesBatch) Add added in v0.4.9

func (b *RepoFilesBatch) Add(f model.RepoFile) error

func (*RepoFilesBatch) Commit added in v0.4.9

func (b *RepoFilesBatch) Commit() (int, error)

func (*RepoFilesBatch) Rollback added in v0.4.9

func (b *RepoFilesBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type ReviewsBatch added in v0.4.9

type ReviewsBatch struct {
	// contains filtered or unexported fields
}

ReviewsBatch buffers model.Review rows.

func (*ReviewsBatch) Add added in v0.4.9

func (b *ReviewsBatch) Add(r model.Review) error

func (*ReviewsBatch) Commit added in v0.4.9

func (b *ReviewsBatch) Commit() (int, error)

func (*ReviewsBatch) Rollback added in v0.4.9

func (b *ReviewsBatch) Rollback()

Rollback marks the batch closed without flushing. No-op once Commit() has run successfully (closed already true). Safe to call via defer.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store wraps a SQLite database and implements connector.Sink with prepared insert statements. Concurrent connector workers share one Store; per-call inserts are serialised behind a mutex so the single connection writer is safe.

func Open

func Open(path string, toolVersion string) (*Store, error)

Open opens (or creates) a SQLite database at path, applies the canonical DDL, records a _schema row capturing the schema and tool versions, and prepares one insert statement per Sink method.

func (*Store) BeginBuildJobsBatch added in v0.4.9

func (s *Store) BeginBuildJobsBatch() (*BuildJobsBatch, error)

func (*Store) BeginBuildsBatch added in v0.4.9

func (s *Store) BeginBuildsBatch() (*BuildsBatch, error)

func (*Store) BeginCommitCoauthorsBatch added in v0.4.9

func (s *Store) BeginCommitCoauthorsBatch() (*CommitCoauthorsBatch, error)

func (*Store) BeginCommitFilesBatch added in v0.4.9

func (s *Store) BeginCommitFilesBatch() (*CommitFilesBatch, error)

func (*Store) BeginCommitsBatch added in v0.4.9

func (s *Store) BeginCommitsBatch() (*CommitsBatch, error)

BeginCommitsBatch opens a new buffered batch for the commits table. The returned handle must have Commit() (or Rollback()) called by the caller; defer Rollback() is safe and idempotent.

func (*Store) BeginFileComplexityHistoryBatch added in v0.4.9

func (s *Store) BeginFileComplexityHistoryBatch() (*FileComplexityHistoryBatch, error)

func (*Store) BeginFileMetricsBatch added in v0.4.9

func (s *Store) BeginFileMetricsBatch() (*FileMetricsBatch, error)

func (*Store) BeginPRCommentsBatch added in v0.4.9

func (s *Store) BeginPRCommentsBatch() (*PRCommentsBatch, error)

func (*Store) BeginPRCommitsBatch added in v0.4.9

func (s *Store) BeginPRCommitsBatch() (*PRCommitsBatch, error)

func (*Store) BeginPRLabelsBatch added in v0.4.9

func (s *Store) BeginPRLabelsBatch() (*PRLabelsBatch, error)

func (*Store) BeginPRsBatch added in v0.4.9

func (s *Store) BeginPRsBatch() (*PRsBatch, error)

func (*Store) BeginRepoFilesBatch added in v0.4.9

func (s *Store) BeginRepoFilesBatch() (*RepoFilesBatch, error)

func (*Store) BeginReviewsBatch added in v0.4.9

func (s *Store) BeginReviewsBatch() (*ReviewsBatch, error)

func (*Store) Close

func (s *Store) Close() error

Close releases prepared statements and the underlying database handle.

func (*Store) DB

func (s *Store) DB() *sql.DB

DB exposes the underlying *sql.DB for cross-cutting passes (postprocess linkage) that need to issue UPDATEs against multiple tables. The store's mutex does not guard direct DB access; callers must coordinate with other writers, which in practice means using DB only after all connector extraction has finished.

func (*Store) InsertBranch

func (s *Store) InsertBranch(b model.Branch) error

func (*Store) InsertBranchProtection

func (s *Store) InsertBranchProtection(b model.BranchProtection) error

func (*Store) InsertBuild

func (s *Store) InsertBuild(b model.Build) error

func (*Store) InsertBuildJob

func (s *Store) InsertBuildJob(j model.BuildJob) error

func (*Store) InsertCodeowner

func (s *Store) InsertCodeowner(c model.Codeowner) error

func (*Store) InsertCommit

func (s *Store) InsertCommit(c model.Commit) error

func (*Store) InsertCommitCoauthor

func (s *Store) InsertCommitCoauthor(c model.CommitCoauthor) error

func (*Store) InsertCommitFile

func (s *Store) InsertCommitFile(c model.CommitFile) error

func (*Store) InsertDefect

func (s *Store) InsertDefect(d model.Defect) error

func (*Store) InsertDeploy

func (s *Store) InsertDeploy(d model.Deploy) error

func (*Store) InsertFileComplexityHistory

func (s *Store) InsertFileComplexityHistory(f model.FileComplexityHistory) error

func (*Store) InsertFileMetric

func (s *Store) InsertFileMetric(f model.FileMetric) error

func (*Store) InsertHarnessArtifact

func (s *Store) InsertHarnessArtifact(h model.HarnessArtifact) error

func (*Store) InsertIncident

func (s *Store) InsertIncident(i model.Incident) error

func (*Store) InsertPR

func (s *Store) InsertPR(p model.PR) error

func (*Store) InsertPRComment

func (s *Store) InsertPRComment(c model.PRComment) error

func (*Store) InsertPRCommit

func (s *Store) InsertPRCommit(p model.PRCommit) error

func (*Store) InsertPRLabel

func (s *Store) InsertPRLabel(l model.PRLabel) error

func (*Store) InsertPRReviewRequest

func (s *Store) InsertPRReviewRequest(r model.PRReviewRequest) error

func (*Store) InsertRelease

func (s *Store) InsertRelease(r model.Release) error

func (*Store) InsertRepo

func (s *Store) InsertRepo(r model.Repo) error

func (*Store) InsertRepoFile

func (s *Store) InsertRepoFile(f model.RepoFile) error

func (*Store) InsertRepoLanguage

func (s *Store) InsertRepoLanguage(r model.RepoLanguage) error

func (*Store) InsertReview

func (s *Store) InsertReview(r model.Review) error

func (*Store) InsertTeamRepo

func (s *Store) InsertTeamRepo(team, repo string) error

func (*Store) SquashStats

func (s *Store) SquashStats() (nSquash, nMerged int, err error)

SquashStats returns counts of merged PRs and squash-merged PRs across the entire artifact. Used by run.go after extraction to populate the manifest's `n_total_merged_prs` / `n_squash_merged_prs` / `squash_rate` fields; assay treats squash_rate > 0.5 as the Tornhill Ch 9 caveat threshold for coupling-derived metrics.

merge_method classification is per ADR 021 (parent count + PR-head reachability), already computed at extract time and stored in the prs.merge_method column — no re-derivation here.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL