store

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSyncStateNotFound = errors.New("sync state key not found")
View Source
var GitHubSourceFields = []string{
	"name",
	"description",
	"url",
	"language",
	"homepage",
	"stargazers_count",
	"forks_count",
	"topics",
	"owner_login",
	"owner_avatar",
	"starred_at",
	"repo_updated_at",
}
View Source
var LocalRepoFields = []string{
	"ai_summary",
	"ai_tags",
	"ai_platforms",
	"ai_search_text",
	"ai_category",
	"analyzed_at",
	"analysis_failed",
	"custom_description",
	"custom_tags",
	"custom_category",
	"category_locked",
}

Functions

func ApplyTags added in v0.1.0

func ApplyTags(current, add, remove []string) []string

func ParseCSV added in v0.1.0

func ParseCSV(s string) []string

func ParseTagExpr added in v0.1.0

func ParseTagExpr(expr string) (add, remove []string)

func Slugify added in v0.1.0

func Slugify(s string) string

Types

type AIResult

type AIResult struct {
	Summary    string
	Tags       []string
	Platforms  []string
	Category   string
	SearchText string
}

type Category

type Category struct {
	ID        string
	Name      string
	Keywords  []string
	SortOrder int
	IsCustom  bool
	IsHidden  bool
}

type CustomFields

type CustomFields struct {
	Description    string
	Tags           []string
	Category       string
	CategoryLocked bool
}

type FTSResult deprecated added in v0.0.5

type FTSResult struct {
	Repo      *Repository
	BM25Score float64
}

Deprecated: FTSResult was used for FTS5 full-text search results. In-memory search now uses ai.SearchHit directly. This type is retained for backward compatibility and may be removed.

type Repository

type Repository struct {
	ID                int64
	FullName          string
	Name              string
	Description       string
	URL               string
	Language          string
	Homepage          string
	StargazersCount   int
	ForksCount        int
	Topics            []string
	OwnerLogin        string
	OwnerAvatar       string
	StarredAt         string
	RepoUpdatedAt     string // 仓库在 GitHub 上的最后更新时间 (RFC3339)
	AISummary         string
	AITags            []string
	AIPlatforms       []string
	AICategory        string
	AISearchText      string
	AnalyzedAt        *time.Time
	AnalysisFailed    bool
	CustomDescription string
	CustomTags        []string
	CustomCategory    string
	CategoryLocked    bool
	VectorIndexedAt   *time.Time
}

func MergeReposOnSync added in v0.0.6

func MergeReposOnSync(incoming []*Repository, existing map[string]*Repository) []*Repository

type SearchFilters added in v0.0.5

type SearchFilters struct {
	Language       string
	Category       string
	MinStars       int
	MaxStars       int
	Platform       string
	Tags           []string
	Limit          int
	Analyzed       *bool
	AnalysisFailed *bool
}

type Store

type Store interface {
	Close() error

	UpsertRepository(ctx context.Context, r *Repository) error
	UpsertRepositories(ctx context.Context, rs []*Repository) error
	UpsertReposOnSync(ctx context.Context, rs []*Repository, fullSync bool) error
	UpsertReposTouchOnly(ctx context.Context, repos []*Repository) error
	GetRepository(ctx context.Context, fullName string) (*Repository, error)
	ListRepositories(ctx context.Context) ([]*Repository, error)
	ListUnanalyzed(ctx context.Context, limit int) ([]*Repository, error)
	ListByCategory(ctx context.Context, category string) ([]*Repository, error)
	UpdateAIResult(ctx context.Context, repoID int64, res *AIResult) error
	UpdateCustomFields(ctx context.Context, repoID int64, f *CustomFields) error
	SetAnalysisFailed(ctx context.Context, repoID int64, failed bool) error
	DeleteAllRepositories(ctx context.Context) error

	// Deprecated: SearchFTS used FTS5 for full-text search.
	// Search is now handled by in-memory matching in the ai package (SearchIndex).
	// This method remains for backward compatibility and may be removed in a future version.
	SearchFTS(ctx context.Context, query string, filters *SearchFilters) ([]*FTSResult, error)
	// Deprecated: RebuildFTSIndex was used to refresh the FTS5 full-text index.
	// This method remains for backward compatibility and may be removed in a future version.
	RebuildFTSIndex(ctx context.Context) error

	InsertVector(ctx context.Context, repoID int64, embedding []float64) error
	SearchVectors(ctx context.Context, queryVec []float64, topK int, threshold float64) ([]VectorMatch, error)
	DeleteVector(ctx context.Context, repoID int64) error
	SetVectorIndexedAt(ctx context.Context, repoID int64, t time.Time) error
	GetRepositoryByID(ctx context.Context, id int64) (*Repository, error)
	ListVectorUnindexed(ctx context.Context, limit int) ([]*Repository, error)
	EnsureVec0Dimension(ctx context.Context, dim int) error

	ListCategories(ctx context.Context, visibleOnly bool) ([]*Category, error)
	UpsertCategory(ctx context.Context, c *Category) error
	DeleteCategory(ctx context.Context, id string) (int, error)

	GetSyncState(ctx context.Context, key string) (string, error)
	SetSyncState(ctx context.Context, key, value string) error
	SaveSyncStats(ctx context.Context, stats *SyncStats) error
	GetSyncStats(ctx context.Context) (*SyncStats, error)
	IncrementSyncCount(ctx context.Context) error
}

func Open

func Open(dbPath string) (Store, error)

type SyncStats added in v0.0.6

type SyncStats struct {
	TotalSyncCount int       `json:"total_sync_count"`
	LastSync       time.Time `json:"last_sync"`
	LastDuration   string    `json:"last_duration"`
	LastRepoCount  int       `json:"last_repo_count"`
	LastNewCount   int       `json:"last_new_count"`
	LastErrorCount int       `json:"last_error_count"`
}

type VectorMatch added in v0.0.6

type VectorMatch struct {
	RepoID     int64
	Distance   float64
	Similarity float64
}

Jump to

Keyboard shortcuts

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