db

package
v0.0.0-...-6320ad3 Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileVersion

type FileVersion struct {
	FileID       int32     `db:"file_id"`
	FileSHA      string    `db:"file_sha"`
	RelativePath string    `db:"relative_path"`
	Ephemeral    bool      `db:"ephemeral"`
	CommitID     *string   `db:"commit_id"`
	Status       string    `db:"status"`
	CreatedAt    time.Time `db:"created_at"`
	UpdatedAt    time.Time `db:"updated_at"`
}

FileVersion represents a versioned file in the repository

type FileVersionRepository

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

FileVersionRepository manages file version operations

func NewFileVersionRepository

func NewFileVersionRepository(db *sql.DB, repoName string, logger *zap.Logger) (*FileVersionRepository, error)

NewFileVersionRepository creates a new repository for managing file versions

func (*FileVersionRepository) DeleteEphemeralVersions

func (r *FileVersionRepository) DeleteEphemeralVersions() (int64, error)

DeleteEphemeralVersions deletes all ephemeral file versions

func (*FileVersionRepository) DropTable

func (r *FileVersionRepository) DropTable() error

DropTable drops the file_versions table for this repository. This permanently deletes all file version tracking data for the repository.

func (*FileVersionRepository) EnsureTable

func (r *FileVersionRepository) EnsureTable() error

EnsureTable creates the file_versions table if it doesn't exist and ensures all required columns are present (handles schema migrations)

func (*FileVersionRepository) GetFileByID

func (r *FileVersionRepository) GetFileByID(fileID int32) (*FileVersion, error)

GetFileByID retrieves a file version by its ID

func (*FileVersionRepository) GetFilesByPath

func (r *FileVersionRepository) GetFilesByPath(relativePath string) ([]*FileVersion, error)

GetFilesByPath retrieves all file versions for a specific path

func (*FileVersionRepository) GetFilesBySHA

func (r *FileVersionRepository) GetFilesBySHA(fileSHA string) ([]*FileVersion, error)

GetFilesBySHA retrieves all file versions with a specific SHA

func (*FileVersionRepository) GetOrCreateFileID

func (r *FileVersionRepository) GetOrCreateFileID(fileSHA, relativePath string, ephemeral bool, commitID *string) (int32, error)

GetOrCreateFileID retrieves existing FileID or creates a new one This is the core method for FileID management

func (*FileVersionRepository) GetStats

func (r *FileVersionRepository) GetStats() (total int64, ephemeral int64, committed int64, err error)

GetStats returns statistics about the file versions

func (*FileVersionRepository) UpdateStatus

func (r *FileVersionRepository) UpdateStatus(fileID int32, status string) error

UpdateStatus updates the processing status of a file version

type MySQLConnection

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

MySQLConnection manages the MySQL database connection

func NewMySQLConnection

func NewMySQLConnection(cfg config.MySQLConfig, logger *zap.Logger) (*MySQLConnection, error)

NewMySQLConnection creates a new MySQL connection pool

func (*MySQLConnection) Close

func (m *MySQLConnection) Close() error

Close closes the database connection

func (*MySQLConnection) EnsureDatabase

func (m *MySQLConnection) EnsureDatabase(dbName string) error

EnsureDatabase creates the database if it doesn't exist and reconnects to use it

func (*MySQLConnection) GetDB

func (m *MySQLConnection) GetDB() *sql.DB

GetDB returns the underlying sql.DB connection

func (*MySQLConnection) Ping

func (m *MySQLConnection) Ping() error

Ping checks if the database connection is alive

func (*MySQLConnection) Stats

func (m *MySQLConnection) Stats() sql.DBStats

Stats returns database statistics

type SummaryStats

type SummaryStats struct {
	Total             int64 `json:"total"`
	Functions         int64 `json:"functions"`
	Classes           int64 `json:"classes"`
	Files             int64 `json:"files"`
	Folders           int64 `json:"folders"`
	Projects          int64 `json:"projects"`
	TotalPromptTokens int64 `json:"total_prompt_tokens"`
	TotalOutputTokens int64 `json:"total_output_tokens"`
}

SummaryStats holds statistics about stored summaries

type SummaryStore

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

SummaryStore manages code summary storage in MySQL

func NewSummaryStore

func NewSummaryStore(db *sql.DB, repoName string, logger *zap.Logger) (*SummaryStore, error)

NewSummaryStore creates a new summary store for a repository

func (*SummaryStore) DeleteAll

func (s *SummaryStore) DeleteAll() (int64, error)

DeleteAll deletes all summaries for the repository

func (*SummaryStore) DeleteByFile

func (s *SummaryStore) DeleteByFile(filePath string) (int64, error)

DeleteByFile deletes all summaries for a file path

func (*SummaryStore) DeleteByType

func (s *SummaryStore) DeleteByType(entityType summary.SummaryLevel) (int64, error)

DeleteByType deletes all summaries of a specific type

func (*SummaryStore) DropTable

func (s *SummaryStore) DropTable() error

DropTable drops the summaries table for this repository

func (*SummaryStore) EnsureTable

func (s *SummaryStore) EnsureTable() error

EnsureTable creates the code_summaries table if it doesn't exist

func (*SummaryStore) GetAllSummaries

func (s *SummaryStore) GetAllSummaries() ([]*summary.CodeSummary, error)

GetAllSummaries retrieves all summaries

func (*SummaryStore) GetFileSummary

func (s *SummaryStore) GetFileSummary(filePath string) (*summary.CodeSummary, error)

GetFileSummary retrieves the file-level summary for a file path

func (*SummaryStore) GetRecentSummaries

func (s *SummaryStore) GetRecentSummaries(since time.Time) ([]*summary.CodeSummary, error)

GetRecentSummaries returns summaries updated after a given time

func (*SummaryStore) GetStats

func (s *SummaryStore) GetStats() (*SummaryStats, error)

GetStats returns statistics about stored summaries

func (*SummaryStore) GetSummariesByFile

func (s *SummaryStore) GetSummariesByFile(filePath string) ([]*summary.CodeSummary, error)

GetSummariesByFile retrieves all summaries for a file path

func (*SummaryStore) GetSummariesByFileAndType

func (s *SummaryStore) GetSummariesByFileAndType(filePath string, entityType summary.SummaryLevel) ([]*summary.CodeSummary, error)

GetSummariesByFileAndType retrieves summaries for a file filtered by entity type

func (*SummaryStore) GetSummariesByType

func (s *SummaryStore) GetSummariesByType(entityType summary.SummaryLevel) ([]*summary.CodeSummary, error)

GetSummariesByType retrieves all summaries of a specific type

func (*SummaryStore) GetSummary

func (s *SummaryStore) GetSummary(entityID string, entityType summary.SummaryLevel) (*summary.CodeSummary, error)

GetSummary retrieves a summary by entity ID and type

func (*SummaryStore) GetSummaryByFileAndName

func (s *SummaryStore) GetSummaryByFileAndName(filePath string, entityType summary.SummaryLevel, entityName string) (*summary.CodeSummary, error)

GetSummaryByFileAndName retrieves a specific summary by file path, entity type and name

func (*SummaryStore) GetSummaryMap

func (s *SummaryStore) GetSummaryMap(entityType summary.SummaryLevel) (map[string]*summary.CodeSummary, error)

GetSummaryMap returns a map of entity ID to summary for quick lookups

func (*SummaryStore) NeedsUpdate

func (s *SummaryStore) NeedsUpdate(entityID string, entityType summary.SummaryLevel, contextHash string) (bool, error)

NeedsUpdate checks if a summary needs to be regenerated based on context hash

func (*SummaryStore) SaveSummaries

func (s *SummaryStore) SaveSummaries(summaries []*summary.CodeSummary) error

SaveSummaries saves multiple summaries in a batch

func (*SummaryStore) SaveSummary

func (s *SummaryStore) SaveSummary(cs *summary.CodeSummary) error

SaveSummary saves or updates a code summary

Jump to

Keyboard shortcuts

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